Skip to content

Commit 821f936

Browse files
author
zoey
committed
feat: /tidewave http paths (#16)
1 parent d8c396a commit 821f936

20 files changed

Lines changed: 1413 additions & 47 deletions

.github/workflows/publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ jobs:
3333
- name: Type check
3434
run: npm run type:check
3535

36-
- name: Build project
37-
run: npm run build
38-
3936
- name: Run tests
4037
run: npx vitest run -c vitest.config.js
4138

39+
- name: Build project
40+
run: npm run dist
41+
4242
- name: Publish to npm
4343
env:
4444
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ Available MCP options:
3030

3131
- `--prefix path` - Specify the directory to find the `package.json` file
3232

33+
### HTTP MCP via Vite Plugin
34+
35+
Tidewave also provides HTTP-based MCP access through a Vite plugin for
36+
development environments. Add the plugin to your `vite.config.js`:
37+
38+
```javascript
39+
import { defineConfig } from 'vite';
40+
import tidewave from 'tidewave/vite-plugin';
41+
42+
export default defineConfig({
43+
plugins: [tidewave()],
44+
});
45+
```
46+
47+
This exposes MCP endpoints at `/tidewave/mcp` and `/tidewave/shell` during
48+
development.
49+
50+
Configuration options:
51+
52+
```javascript
53+
tidewave({
54+
allowRemoteAccess: false, // Allow access from remote IPs
55+
allowedOrigins: ['localhost'], // Allowed origins: defaults to the Vite's host+port
56+
});
57+
```
58+
3359
### CLI Usage
3460

3561
Tidewave also provides the MCP features over a CLI tool. Use it directly via

bun.lock

Lines changed: 170 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export default [
5353
// Function style preferences
5454
'prefer-arrow-callback': 'error',
5555
'arrow-body-style': ['error', 'as-needed'],
56-
'func-style': ['error', 'declaration'], // Prefer function declarations for better stack traces
56+
// Prefer function declarations for better stack traces
57+
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
5758
},
5859
},
5960
{

flake.nix

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05-small";
44
};
55

6-
outputs = {
7-
nixpkgs,
8-
...
9-
}: let
6+
outputs = {nixpkgs, ...}: let
107
inherit (nixpkgs.lib) genAttrs;
118
inherit (nixpkgs.lib.systems) flakeExposed;
129
forAllSystems = f:
@@ -20,12 +17,16 @@
2017
in {
2118
default = mkShell {
2219
name = "tidewave-javascript";
23-
packages = with pkgs; [
24-
bun
25-
# nodejs_24
26-
# nodePackages.npm
27-
typescript
28-
] ++ lib.optional stdenv.isLinux [inotify-tools];
20+
packages = with pkgs;
21+
[
22+
bun
23+
# with homebrew
24+
# nodejs_24
25+
# nodePackages.npm
26+
typescript
27+
just
28+
]
29+
++ lib.optional stdenv.isLinux [inotify-tools];
2930
};
3031
});
3132

justfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
curl-mcp body='{}' port='5001':
2+
curl -X POST \
3+
-H 'accept: application/json,text/event-stream' \
4+
-H 'content-type: application/json' \
5+
-d '{{body}}' \
6+
http://localhost:{{port}}/tidewave/mcp
7+
8+
initialize-mcp:
9+
@just curl-mcp '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-03-26","clientInfo":{"name":"curl-test","version":"1.0.0"},"capabilities":{}},"id":1}'
10+
11+
list-tools-mcp port='5001':
12+
@just curl-mcp '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":2}' {{port}}
13+
14+
curl-shell command port='5001':
15+
curl -X POST http://localhost:{{port}}/tidewave/shell \
16+
-H 'content-type: application/json' \
17+
-H 'accept: text/event-stream,application/json' \
18+
-d '{"command": "{{command}}"}' \
19+
--output -
20+
21+
default:
22+
@just --choose

package-lock.json

Lines changed: 115 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"CHANGELOG.md"
3030
],
3131
"scripts": {
32-
"dist": "bun build --outdir dist --root src --external commander --external chalk --external typescript src/**/*.ts --target node",
32+
"dist": "bun build --outdir dist --root src --external commander --external chalk --external typescript src/**/*.ts src/*.ts --target node",
3333
"dev": "bun run src/cli/index.ts",
3434
"test": "bun test",
3535
"lint": "eslint src/ --ext .ts,.js",
@@ -41,14 +41,18 @@
4141
},
4242
"dependencies": {
4343
"@modelcontextprotocol/sdk": "^1.17.4",
44+
"body-parser": "^2.2.0",
4445
"chalk": "^5.3.0",
4546
"commander": "^12.1.0",
47+
"connect": "^3.7.0",
4648
"typescript": "^5",
4749
"zod": "3.25.76"
4850
},
4951
"devDependencies": {
5052
"@eslint/js": "^9.16.0",
53+
"@types/body-parser": "^1.19.6",
5154
"@types/bun": "latest",
55+
"@types/connect": "^3.4.38",
5256
"@types/node": "^22.10.1",
5357
"@typescript-eslint/eslint-plugin": "^8.18.0",
5458
"@typescript-eslint/parser": "^8.18.0",
@@ -57,6 +61,7 @@
5761
"eslint": "^9.16.0",
5862
"globals": "^15.14.0",
5963
"prettier": "^3.4.2",
64+
"vite": "^7.1.5",
6065
"vitest": "^3.2.4"
6166
},
6267
"peerDependencies": {

src/cli/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ async function handleGetSourcePath(
6060
console.log(sourceResult.path);
6161
}
6262

63-
async function handleMcp(options: { prefix?: string }): Promise<void> {
63+
interface McpOptions {
64+
prefix?: string;
65+
}
66+
67+
async function handleMcp(options: McpOptions): Promise<void> {
6468
if (options.prefix) chdir(options.prefix);
65-
console.error('Starting tidewave MCP server using stdio');
69+
70+
console.log('[Tidewave] Starting MCP server');
71+
6672
const transport = new StdioServerTransport(process.stdin, process.stdout);
6773
await serveMcp(transport);
6874
}

src/evaluation/eval_worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { EvaluationRequest } from '../core';
22

33
process.on('message', async ({ code, args }: EvaluationRequest) => {
44
if (!process.send) {
5-
console.error('Unable to establish communication channel with code-executor.');
5+
console.error('[Tidewave] Unable to establish communication channel with code-executor.');
66
process.exit(1);
77
}
88

0 commit comments

Comments
 (0)