ai icon indicating copy to clipboard operation
ai copied to clipboard

Add support for Streamable HTTP mcp tools

Open perfectbase opened this issue 6 months ago • 1 comments
trafficstars

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

perfectbase avatar Apr 25 '25 08:04 perfectbase

This is my workaround for now: https://gist.github.com/perfectbase/d134c174e9e6c479727c160f6997f0e6 (AI generated, but seems to work fine)

perfectbase avatar Apr 25 '25 09:04 perfectbase

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?

iteratetograceness avatar Apr 28 '25 14:04 iteratetograceness

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.

perfectbase avatar Apr 28 '25 23:04 perfectbase

I'm currently using a custom workaround as well.

jasan-s avatar Apr 29 '25 04:04 jasan-s

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.

DerJacques avatar Apr 29 '25 04:04 DerJacques

@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!

iteratetograceness avatar Apr 29 '25 06:04 iteratetograceness