File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed
Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 66 "paths" : {
77 "*" : [" ./*" ],
88 "@modelcontextprotocol/server" : [" ./node_modules/@modelcontextprotocol/server/src/index.ts" ],
9+ "@modelcontextprotocol/express" : [" ./node_modules/@modelcontextprotocol/express/src/index.ts" ],
910 "@modelcontextprotocol/core" : [
1011 " ./node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/src/index.ts"
1112 ],
Original file line number Diff line number Diff line change 1+ # @modelcontextprotocol/express
2+
3+ Express middleware and OAuth server support for MCP.
4+
5+ ## Installation
6+
7+ ``` bash
8+ npm install @modelcontextprotocol/express
9+ ```
10+
11+ ## Exports
12+
13+ - ` createMcpExpressApp() ` - Create an Express app with MCP-compatible middleware
14+ - ` mcpAuthRouter() ` - OAuth 2.0 authorization server router
15+ - ` requireBearerAuth() ` - Bearer token authentication middleware
16+ - ` mcpAuthMetadataRouter() ` - Protected resource metadata endpoints
17+
18+ ## Usage
19+
20+ ``` typescript
21+ import { createMcpExpressApp , mcpAuthRouter } from ' @modelcontextprotocol/express' ;
22+ import { StreamableHTTPServerTransport } from ' @modelcontextprotocol/node' ;
23+ import { McpServer } from ' @modelcontextprotocol/server' ;
24+
25+ const app = createMcpExpressApp ();
26+ const server = new McpServer ({ name: ' my-server' , version: ' 1.0.0' });
27+
28+ app .post (' /mcp' , async (req , res ) => {
29+ const transport = new StreamableHTTPServerTransport ({ sessionIdGenerator : () => crypto .randomUUID () });
30+ await server .connect (transport );
31+ await transport .handleRequest (req , res , req .body );
32+ });
33+
34+ app .listen (3000 );
35+ ```
Original file line number Diff line number Diff line change 1+ # @modelcontextprotocol/node
2+
3+ Node.js HTTP adapters for MCP servers. Wraps the Web Standards ` HTTPServerTransport ` for compatibility with Node.js HTTP types (` IncomingMessage ` /` ServerResponse ` ).
4+
5+ ## Installation
6+
7+ ``` bash
8+ npm install @modelcontextprotocol/node
9+ ```
10+
11+ ## Exports
12+
13+ - ` StreamableHTTPServerTransport ` - HTTP transport for Node.js servers
14+ - ` SSEServerTransport ` - Legacy SSE transport (protocol version 2024-11-05)
15+
16+ ## Usage
17+
18+ ``` typescript
19+ import { StreamableHTTPServerTransport } from ' @modelcontextprotocol/node' ;
20+ import { McpServer } from ' @modelcontextprotocol/server' ;
21+ import http from ' node:http' ;
22+
23+ const server = new McpServer ({ name: ' my-server' , version: ' 1.0.0' });
24+ const transport = new StreamableHTTPServerTransport ({
25+ sessionIdGenerator : () => crypto .randomUUID ()
26+ });
27+
28+ await server .connect (transport );
29+
30+ http .createServer ((req , res ) => {
31+ transport .handleRequest (req , res );
32+ }).listen (3000 );
33+ ```
You can’t perform that action at this time.
0 commit comments