Adds Fastify Middleware for v2 by andyfleming · Pull Request #1536 · modelcontextprotocol/typescript-sdk
This adds middleware for Fastify in the same format as the other adapters/middleware (for hono and express).
Motivation and Context
This adds support for fastify as discussed in the SDK V2 Issue.
- See SDK V2 #809
- Also discussed in Fastify support or custom HTTP adapter? #441
How Has This Been Tested?
- Unit tests (equivalent to the other adapters/middleware)
- Manually tested by consuming this package with MCP server using Fastify.
Breaking Changes
None.
Types of changes
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
- Documentation update
Checklist
- I have read the MCP Documentation
- My code follows the repository's style guidelines
- New and existing tests pass locally
- I have added appropriate error handling
- I have added or updated documentation as needed
Additional context
One small difference in behavior is that this middleware uses the Fastify logger rather than console.warn like the other middleware.