diff --git a/docs/publishing/guides/py-fastmcp.mdx b/docs/publishing/guides/py-fastmcp.mdx index b71a6e25..0efb513c 100644 --- a/docs/publishing/guides/py-fastmcp.mdx +++ b/docs/publishing/guides/py-fastmcp.mdx @@ -3,4 +3,54 @@ title: Python FastMCP description: This guide shows how to publish an MCP server to Agentic using the Python fastmcp package. --- -**TODO** +[Python's FastMCP](https://gofastmcp.com) is a popular [open source](https://github.com/jlowin/fastmcp) MCP server framework for Python. + +## 1. Install the `fastmcp` package + + + +```bash uv +uv add fastmcp +``` + +```bash pip +pip install fastmcp +``` + + + +## 2. Create a FastMCP server + +```py server.py +from fastmcp import FastMCP + +mcp = FastMCP("Demo 🚀") + +@mcp.tool +def add(a: int, b: int) -> int: + """Add two numbers""" + return a + b + +if __name__ == "__main__": + mcp.run(transport="http", host="127.0.0.1", port=8000, path="/mcp") +``` + + + Make sure to run your server with the `transport="http"` option to use the + Streamable HTTP transport. + + +## 3. Deploy your server + +Deploy your server publicly or use a tool like [ngrok](https://ngrok.com) to expose it to the internet. + + + Tools like `ngrok` expose your unauthenticated server to the internet. Only + run this command in a safe environment if you understand the risks. + + +We recommend deploying your server to a cloud provider like [render](https://render.com/docs/deploy-fastapi), [platform.sh](https://docs.platform.sh/languages/python.html), [porter](https://docs.porter.run/guides/fastapi/deploy-fastapi), or [fly.io](https://fly.io/docs/python/frameworks/fastapi/). Or one of the big boys [AWS](https://aws.amazon.com), [GCP](https://cloud.google.com), or [Azure](https://azure.microsoft.com). + +## 4. Deploy your origin MCP server to Agentic + +Now that you have a publicly available MCP server, you can follow the [existing MCP server guide](/publishing/guides/existing-mcp-server) to deploy it to Agentic. diff --git a/docs/publishing/guides/ts-fastmcp.mdx b/docs/publishing/guides/ts-fastmcp.mdx index 30436d23..08f624eb 100644 --- a/docs/publishing/guides/ts-fastmcp.mdx +++ b/docs/publishing/guides/ts-fastmcp.mdx @@ -3,4 +3,77 @@ title: TS FastMCP description: This guide shows how to publish an MCP server to Agentic using the TypeScript fastmcp package. --- -**TODO** +[FastMCP](https://github.com/punkpeye/fastmcp) is a popular open source MCP server framework for TypeScript. + +## 1. Install dependencies + + + +```bash npm +npm add fastmcp zod +``` + +```bash pnpm +pnpm add fastmcp zod +``` + +```bash bun +bun add fastmcp zod +``` + +```bash yarn +yarn add fastmcp zod +``` + + + +## 2. Create a FastMCP server + +```ts server.ts +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 + } +}) +``` + + + Make sure to run your server with the `transportType: 'httpStream'` option to + use the Streamable HTTP transport. + + +## 3. Deploy your server + +Deploy your server publicly or use a tool like [ngrok](https://ngrok.com) to expose it to the internet. + + + Tools like `ngrok` expose your unauthenticated server to the internet. Only + run this command in a safe environment if you understand the risks. + + +We recommend deploying your server to a cloud provider like [cloudflare workers](https://workers.cloudflare.com), [vercel](https://vercel.com/guides/hosting-backend-apis), [render](https://render.com/docs/deploy-fastapi) (for instance, using the [hono](https://vercel.com/templates/hono/hono-on-vercel) API template), [porter](https://docs.porter.run/guides/nodejs/deploy-nodejs), or [fly.io](https://fly.io/docs/python/frameworks/fastapi/). Or one of the big boys [AWS](https://aws.amazon.com), [GCP](https://cloud.google.com), or [Azure](https://azure.microsoft.com). + +## 4. Deploy your origin MCP server to Agentic + +Now that you have a publicly available MCP server, you can follow the [existing MCP server guide](/publishing/guides/existing-mcp-server) to deploy it to Agentic. diff --git a/docs/publishing/guides/ts-mcp-hono.mdx b/docs/publishing/guides/ts-mcp-hono.mdx index b45b0708..5732f39c 100644 --- a/docs/publishing/guides/ts-mcp-hono.mdx +++ b/docs/publishing/guides/ts-mcp-hono.mdx @@ -3,4 +3,95 @@ title: TS MCP Hono description: This guide shows how to publish an MCP server to Agentic using TypeScript and Hono's MCP support. --- -**TODO** +[Hono](https://hono.dev) is a popular open source framework for building HTTP servers, and `@hono/mcp`](https://github.com/honojs/middleware/tree/main/packages/mcp) is a Hono middleware for MCP servers. + +## 1. Install dependencies + + + +```bash npm +npm add hono @hono/node-server @hono/mcp @modelcontextprotocol/sdk zod +``` + +```bash pnpm +pnpm add hono @hono/node-server @hono/mcp @modelcontextprotocol/sdk zod +``` + +```bash bun +bun add hono @hono/node-server @hono/mcp @modelcontextprotocol/sdk zod +``` + +```bash yarn +yarn add hono @hono/node-server @hono/mcp @modelcontextprotocol/sdk zod +``` + + + +## 2. Create a Hono MCP Node.js server + +```ts server.ts +import { StreamableHTTPTransport } from '@hono/mcp' +import { serve } from '@hono/node-server' +import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js' +import { Hono } from 'hono' +import { logger } from 'hono/logger' +import { z } from 'zod' + +const app = new Hono() +app.use(logger()) + +const mcpServer = new McpServer({ + name: 'Example', + version: '0.0.1' +}) + +mcpServer.registerTool( + 'add', + { + description: 'Add two numbers', + inputSchema: z.object({ + a: z.number(), + b: z.number() + }) + }, + async (args) => { + return { + content: [ + { + type: 'text', + content: String(args.a + args.b) + } + ] + } + } +) + +app.all('/mcp', async (c) => { + const transport = new StreamableHTTPTransport() + await mcpServer.connect(transport) + return transport.handleRequest(c) +}) + +serve({ fetch: app.fetch, port: 8787 }) +``` + + + Hono is really flexible, so if you'd rather deploy your server to Cloudflare + Workers instead of using Node.js (or any other platform), just follow [Hono's + docs](https://hono.dev/docs/getting-started/basic). + + +## 3. Deploy your server + +Deploy your server publicly or use a tool like [ngrok](https://ngrok.com) to expose it to the internet. + + + Tools like `ngrok` expose your unauthenticated server to the internet. Only + run this command in a safe environment if you understand the risks. + + +We recommend deploying your server to a cloud provider like [cloudflare workers](https://workers.cloudflare.com), [vercel](https://vercel.com/guides/hosting-backend-apis), [render](https://render.com/docs/deploy-fastapi) (for instance, using the [hono](https://vercel.com/templates/hono/hono-on-vercel) API template), [porter](https://docs.porter.run/guides/nodejs/deploy-nodejs), or [fly.io](https://fly.io/docs/python/frameworks/fastapi/). Or one of the big boys [AWS](https://aws.amazon.com), [GCP](https://cloud.google.com), or [Azure](https://azure.microsoft.com). + +## 4. Deploy your origin MCP server to Agentic + +Now that you have a publicly available MCP server, you can follow the [existing MCP server guide](/publishing/guides/existing-mcp-server) to deploy it to Agentic. diff --git a/docs/publishing/guides/ts-openapi-hono.mdx b/docs/publishing/guides/ts-openapi-hono.mdx index f43846c3..5bd510de 100644 --- a/docs/publishing/guides/ts-openapi-hono.mdx +++ b/docs/publishing/guides/ts-openapi-hono.mdx @@ -3,4 +3,102 @@ title: TS OpenAPI Hono description: This guide shows how to publish an OpenAPI service to Agentic using TypeScript and Hono's OpenAPI support. --- -**TODO** +[Hono](https://hono.dev) is a popular open source framework for building HTTP servers, and `@hono/zod-openapi`](https://hono.dev/examples/zod-openapi) is an excellent solution for auto-generating an OpenAPI spec from your Hono routes. + +## 1. Install dependencies + + + +```bash npm +npm add hono @hono/node-server @hono/zod-openapi zod +``` + +```bash pnpm +pnpm add hono @hono/node-server @hono/zod-openapi zod +``` + +```bash bun +bun add hono @hono/node-server @hono/zod-openapi zod +``` + +```bash yarn +yarn add hono @hono/node-server @hono/zod-openapi zod +``` + + + +## 2. Create a Hono OpenAPI Node.js server + +```ts server.ts +import { serve } from '@hono/node-server' +import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi' +import { logger } from 'hono/logger' + +const app = new OpenAPIHono() +app.use(logger()) + +const echoRoute = createRoute({ + description: 'Echoes the request body', + // The OpenAPI `operationId` will be used as the tool name in Agentic + operationId: 'echo', + method: 'post', + path: '/echo', + request: { + body: { + content: { + 'application/json': { + schema: z.object({}).passthrough() + } + } + } + }, + responses: { + 200: { + description: 'Echoed request body', + content: { + 'application/json': { + schema: z.object({}).passthrough() + } + } + } + } +}) + +return app.openapi(echoRoute, async (c) => { + return c.json(c.req.valid('json')) +}) + +app.doc31('/docs', { + openapi: '3.1.0', + info: { + title: 'Example', + description: 'Example description', + version: '0.0.1' + } +}) + +serve({ fetch: app.fetch, port: 8787 }) +``` + +Note that the auto-generated OpenAPI spec will be available at `/docs` in this example. + + + Hono is really flexible, so if you'd rather deploy your server to Cloudflare + Workers instead of using Node.js (or any other platform), just follow [Hono's + docs](https://hono.dev/docs/getting-started/basic). + + +## 3. Deploy your server + +Deploy your server publicly or use a tool like [ngrok](https://ngrok.com) to expose it to the internet. + + + Tools like `ngrok` expose your unauthenticated server to the internet. Only + run this command in a safe environment if you understand the risks. + + +We recommend deploying your server to a cloud provider like [cloudflare workers](https://workers.cloudflare.com), [vercel](https://vercel.com/guides/hosting-backend-apis), [render](https://render.com/docs/deploy-fastapi) (for instance, using the [hono](https://vercel.com/templates/hono/hono-on-vercel) API template), [porter](https://docs.porter.run/guides/nodejs/deploy-nodejs), or [fly.io](https://fly.io/docs/python/frameworks/fastapi/). Or one of the big boys [AWS](https://aws.amazon.com), [GCP](https://cloud.google.com), or [Azure](https://azure.microsoft.com). + +## 4. Deploy your origin OpenAPI service to Agentic + +Now that you have a publicly available MCP server, you can follow the [existing OpenAPI server guide](/publishing/guides/existing-openapi-server) to deploy it to Agentic.