Skip to content

Commit e14ecae

Browse files
committed
docs(readme): update
1 parent 0901a4c commit e14ecae

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ xsMCP v0.1 is targeted to be compatible with the `2025-03-26` revision and is no
2525
`@xsmcp/server-http` is based on [Web Standards](https://hono.dev/docs/concepts/web-standard), not Express.
2626

2727
```ts
28-
import { fetch } from '@xsmcp/server-http'
28+
import { createFetch } from '@xsmcp/server-http'
2929
import { createServer } from '@xsmcp/server-shared'
3030
import { serve } from 'srvx'
3131

@@ -38,22 +38,19 @@ for (const tool of tools) {
3838
}
3939

4040
// (req: Request) => Promise<Response>
41-
const app = fetch(server)
41+
const fetch = createFetch(server)
4242

4343
// node.js, deno, bun
44-
serve({ fetch: app })
44+
serve({ fetch })
4545

46-
// next.js
47-
export const POST = app
48-
49-
// cloudflare workers
50-
export default { fetch: app }
46+
// cloudflare workers, pages
47+
export default { fetch }
5148
```
5249

5350
It can be used as a server on its own or with `hono`, `elysia` and `itty-router` for more features:
5451

5552
```ts
56-
import { fetch } from '@xsmcp/server-http'
53+
import { createFetch } from '@xsmcp/server-http'
5754
import { createServer } from '@xsmcp/server-shared'
5855
import { Elysia } from 'elysia'
5956
import { Hono } from 'hono'
@@ -67,19 +64,19 @@ for (const tool of tools) {
6764
server.addTool(tool)
6865
}
6966

70-
const app = fetch(server)
67+
const fetch = createFetch(server)
7168

7269
// hono
7370
new Hono()
74-
.post('/mcp', ({ req }) => app(req.raw))
71+
.post('/mcp', ({ req }) => fetch(req.raw))
7572

7673
// elysia
7774
new Elysia()
78-
.post('/mcp', ({ request }) => app(request))
75+
.post('/mcp', ({ request }) => fetch(request))
7976

8077
// itty-router
8178
AutoRouter()
82-
.post('/mcp', req => app(req))
79+
.post('/mcp', req => fetch(req))
8380
```
8481

8582
At the same time, it does not depends on any server framework thus minimizing the size.

0 commit comments

Comments
 (0)