ai
ai copied to clipboard
Add support for Streamable HTTP mcp tools
Description
The SSE transport is now deprecated. The new MCP transport is Streamable HTTP, which can be deployed to stateless serverless environments. It would be nice to have native support for this transport in the ai-sdk.
https://github.com/modelcontextprotocol/typescript-sdk?tab=readme-ov-file#streamable-http
This is my workaround for now: https://gist.github.com/perfectbase/d134c174e9e6c479727c160f6997f0e6 (AI generated, but seems to work fine)
Hi @perfectbase! Could you help share additional context around what you're hoping to get out of native support for the HTTP transport? Are you running into any particular issues?
Hi @iteratetograceness Right now the ai-sdk has support to add tools from MCPs. It works with the "stdio" transport and with the "sse" transport, but it does not work with the new "streamable http" transport (which is going to be the main way people build MCPs going forward). This is basically the main issue I had.
I'm currently using a custom workaround as well.
Just chiming in to say that I ran into this issue as I tried to integrate Vercel/ai with an MCP server that I had spun up based on the official Typescript MCP server guide: https://github.com/modelcontextprotocol/typescript-sdk
I could see many other people run into the same issue.
@perfectbase @jasan-s @DerJacques please check out examples/mcp/src/http/client.ts in the PR linked above, the experimental client already works with the streamable HTTP transport from MCP's official TS SDK to fetch and call tools.
If you're still running into issues, could you provide additional details around the errors you're seeing? Sharing a code snippet would be the most helpful!