tidewave 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Simply configure your editor to run `tidewave` in the same directory as your
20
20
 
21
21
  ```bash
22
22
  npx tidewave mcp
23
- # or
23
+ # or with Bun
24
24
  bunx tidewave mcp
25
25
  # or with Deno
26
26
  deno run npm:tidewave mcp
@@ -30,6 +30,96 @@ Available MCP options:
30
30
 
31
31
  - `--prefix path` - Specify the directory to find the `package.json` file
32
32
 
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
+
59
+ ### HTTP MCP via Next.js Integration
60
+
61
+ Tidewave provides seamless integration with Next.js through a handler function.
62
+ Add the handler to your API routes **and** `middleware.ts`:
63
+
64
+ > [!WARNING] Note that the below helper functions will only work on development
65
+ > mode `NODE_ENV === 'development'` if the validation fails, an Error will be
66
+ > thrown
67
+
68
+ **Pages Router** - Create `pages/api/tidewave/[...all].ts`:
69
+
70
+ ```typescript
71
+ import { tidewaveHandler } from 'tidewave/next-js';
72
+
73
+ export default await tidewaveHandler();
74
+
75
+ // Next.js specific config
76
+ export const config = {
77
+ runtime: 'nodejs',
78
+ api: {
79
+ bodyParser: false, // tidewave already parses the body internally
80
+ },
81
+ };
82
+ ```
83
+
84
+ This exposes MCP endpoints at `/api/tidewave/mcp` and `/api/tidewave/shell`.
85
+
86
+ Then create `middleware.ts` with:
87
+
88
+ ```typescript
89
+ import { tidewaveMiddleware } from 'tidewave/next-js';
90
+
91
+ export const middleware = tidewaveMiddleware();
92
+
93
+ export const config = {
94
+ matcher: '/tidewave/(.*)',
95
+ };
96
+ ```
97
+
98
+ In case you already have an existing `middleware.ts`:
99
+
100
+ ```typescript
101
+ import { tidewaveMiddleware } from 'tidewave/next-js';
102
+
103
+ const withTidewave = tidewaveMiddleware();
104
+
105
+ export function middleware(req: NextRequest): Promise<NextResponse> {
106
+ // This will return a unchanged NextResponse.next()
107
+ // if path doesn't match with `/tidewave`
108
+ // if does match it will rewrite to `/api/tidewave` instead
109
+ withTidewave(req, (req: NextRequest) => {
110
+ // your own logic
111
+ return NextResponse.json({ message: 'hello, world!' });
112
+ });
113
+ }
114
+
115
+ export const config = {
116
+ matcher: [
117
+ '/tidewave/(.*)', // tidewave specific matcher
118
+ '/your/route/', // your specific matcher
119
+ ],
120
+ };
121
+ ```
122
+
33
123
  ### CLI Usage
34
124
 
35
125
  Tidewave also provides the MCP features over a CLI tool. Use it directly via
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};