Merge branch 'main' into main

This commit is contained in:
David Dworken 2025-06-26 16:10:00 -07:00 • committed by GitHub
commit 185fb23f34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -504,6 +504,21 @@ app.delete('/mcp', handleSessionRequest);
app.listen(3000);
```
> [!TIP]
> When using this in a remote environment, make sure to allow the header parameter `mcp-session-id` in CORS. Otherwise, it may result in a `Bad Request: No valid session ID provided` error.
>
> For example, in Node.js you can configure it like this:
>
> ```ts
> app.use(
> cors({
> origin: ['https://your-remote-domain.com, https://your-other-remote-domain.com'],
> exposedHeaders: ['mcp-session-id'],
> allowedHeaders: ['Content-Type', 'mcp-session-id'],
> })
> );
> ```
#### Without Session Management (Stateless)
For simpler use cases where session management isn't needed:
@ -544,6 +559,7 @@ app.post('/mcp', async (req: Request, res: Response) => {
}
});
// SSE notifications not supported in stateless mode
app.get('/mcp', async (req: Request, res: Response) => {
console.log('Received GET MCP request');
res.writeHead(405).end(JSON.stringify({
@ -556,6 +572,7 @@ app.get('/mcp', async (req: Request, res: Response) => {
}));
});
// Session termination not needed in stateless mode
app.delete('/mcp', async (req: Request, res: Response) => {
console.log('Received DELETE MCP request');
res.writeHead(405).end(JSON.stringify({
@ -950,7 +967,7 @@ Client-side: Handle elicitation requests
```typescript
// This is a placeholder - implement based on your UI framework
async function getInputFromUser(message: string, schema: any): Promise<{
action: "accept" | "decline" | "cancel";
action: "accept" | "reject" | "cancel";
data?: Record<string, any>;
}> {
// This should be implemented depending on the app