docs/publishing/guides/ts-fastmcp.mdx
FastMCP is a popular open source TypeScript framework for building MCP servers.
npm add fastmcp zod
pnpm add fastmcp zod
bun add fastmcp zod
yarn add fastmcp zod
import { FastMCP } from 'fastmcp'
import { z } from 'zod' // Or any validation library that supports Standard Schema
const server = new FastMCP({
name: 'Example',
version: '0.0.1'
})
server.addTool({
name: 'add',
description: 'Add two numbers',
parameters: z.object({
a: z.number(),
b: z.number()
}),
execute: async (args) => {
return String(args.a + args.b)
}
})
server.start({
transportType: 'httpStream',
httpStream: {
port: 8080
}
})
Deploy your server publicly or use a tool like ngrok to expose it to the internet.
<Warning> Tools like `ngrok` expose your unauthenticated server to the internet. Only run this command in a safe environment if you understand the risks. </Warning>We recommend deploying your server to a cloud provider like Cloudflare Workers, Vercel (for instance, using the Hono API template), Render, Porter, or Fly.io. Or one of the big boys AWS, GCP, or Azure.
Now that you have a publicly available MCP server, you can follow the existing MCP server guide to deploy it to Agentic.