Skip to content

Fastify support or custom HTTP adapter? #441

Closed

Description

@Njuelle

Hi team,

I’m wondering how to use the MCP TypeScript SDK with a backend (NestJS) that uses Fastify instead of Express?

Currently, the SDK seems to be tightly coupled with Express, but it could be a great feature to support Fastify or provide a way to use a custom HTTP adapter so users can integrate their own.
What do you think would be the best approach?

I’d be happy to work on a PR for this :)

Thanks in advance!

Activity

  1. added
    enhancementRequest for a new feature that's not currently supported
    on May 3, 2025
  2. haroldadmin commented on May 4, 2025

    @haroldadmin

    Hi, I maintain a plugin to run MCP servers over Fastify. I'm working on adding support for Streamable HTTP support, and it should be out soon it's out now!

    https://github.com/haroldadmin/fastify-mcp

  3. eddyv commented on May 20, 2025

    @eddyv

    Hm, i never had issues running mcp servers on fastify - anything in particular you had issues setting up? You can check out our impl here https://github.com/confluentinc/mcp-confluent/blob/c0927bc9def221105edff74b8f1a8fd36af2e092/src/mcp/transports/http.ts. Hopefully, this helps :)

  4. added a commit that references this issue on Aug 20, 2025
  5. sjoerdvanBommel commented on Aug 22, 2025

    @sjoerdvanBommel

    I've noticed several hooks such as onSend hook are skipped on tool call. I think this has to do with the fact that request.raw is used behind the scenes. See this blog post. Has anyone encountered the same, who was able to resolve this?

  6. sjoerdvanBommel commented on Aug 22, 2025

    @sjoerdvanBommel

    Since we're skipping all the Fastify logic of handling the HTTP response when using request.raw, it will not execute further fastify hooks such as onSend.

    I'm surprised though that the intialize and notifications/initialized methods behave different. In those cases, the hooks still get called. EDIT: initialize and notifications/initialized do not behave different. It looked like they did, because the onSend hook gets called. However, this is because during initialization, the GET endpoint is being called as well because of session management, which does not skip fastify HTTP response handling.

  7. KKonstantinov commented on Dec 5, 2025

    @KKonstantinov
    Contributor

    v2 will make it easier for many frameworks to integrate with - using web standards. follow #809 for it.

  8. added this to the v2 milestone on Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequest for a new feature that's not currently supported

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions