Documentation Index Fetch the complete documentation index at: https://mintlify.com/punkpeye/fastmcp/llms.txt
Use this file to discover all available pages before exploring further.
The EdgeFastMCP class provides edge runtime compatibility for FastMCP, enabling deployment to Cloudflare Workers, Deno Deploy, and other edge platforms. It uses only web-standard APIs (no Node.js dependencies).
Constructor
Create a new EdgeFastMCP server instance.
import { EdgeFastMCP } from "fastmcp/edge" ;
const server = new EdgeFastMCP ({
name: "my-edge-server" ,
version: "1.0.0" ,
});
Semantic version string (e.g., “1.0.0”)
Custom logger instance (defaults to console)
Base path for MCP endpoints
Methods
Register a tool that can be called by the MCP client.
import { z } from "zod" ;
server . addTool ({
name: "get_time" ,
description: "Get current time" ,
parameters: z . object ({
timezone: z . string (). optional (),
}),
execute : async ({ timezone }) => {
return new Date (). toLocaleString ( "en-US" , { timeZone: timezone });
},
});
Tool configuration object Human-readable tool description
parameters
StandardSchemaV1 | z.ZodType
Parameter schema (Zod or Standard Schema)
execute
(params) => Promise<string | ContentResult>
required
Tool execution function execute : async ( params ) => {
// Return string
return "Simple text result" ;
// Or return content array
return {
content: [
{ type: "text" , text: "Result" },
{ type: "image" , data: base64Data , mimeType: "image/png" },
],
};
}
addResource()
Register a static resource.
server . addResource ({
uri: "edge://config" ,
name: "Configuration" ,
description: "Edge server config" ,
mimeType: "application/json" ,
load : async () => ({
text: JSON . stringify ({ edge: true }),
}),
});
Resource configuration object Unique resource identifier (URI)
Human-readable resource description
MIME type of the resource content
load
() => Promise<string | ResourceResult>
required
Function that loads resource content load : async () => {
// Return string
return "Resource content" ;
// Or return structured result
return {
text: "Text content" ,
mimeType: "text/plain" ,
};
}
addPrompt()
Register a prompt template.
server . addPrompt ({
name: "summarize" ,
description: "Summarize text" ,
arguments: [
{ name: "text" , description: "Text to summarize" , required: true },
],
load : async ({ text }) => ({
messages: [
{
role: "user" ,
content: { type: "text" , text: `Summarize: ${ text } ` },
},
],
}),
});
Prompt configuration object Human-readable prompt description
arguments
Array<{name: string, description?: string, required?: boolean}>
Prompt argument definitions
load
(args: Record<string, string>) => Promise<string | PromptMessages>
required
Function that generates prompt messages load : async ( args ) => {
// Return string
return "Simple prompt text" ;
// Or return message structure
return {
messages: [
{
role: "user" ,
content: { type: "text" , text: "Prompt content" },
},
],
};
}
fetch()
Handle incoming requests. This is the main entry point for edge runtimes.
// Cloudflare Workers
export default {
async fetch ( request : Request ) : Promise < Response > {
return server . fetch ( request );
} ,
} ;
// Deno Deploy
Deno . serve (( request ) => server . fetch ( request ));
// Bun
Bun . serve ({
fetch : ( request ) => server . fetch ( request ),
port: 8000 ,
});
getApp()
Get the underlying Hono app instance for adding custom routes.
const app = server . getApp ();
app . get ( "/health" , ( c ) => c . text ( "OK" ));
app . post ( "/webhook" , async ( c ) => {
const data = await c . req . json ();
return c . json ({ received: true });
});
Hono application instance
Differences from FastMCP
EdgeFastMCP is a simplified implementation optimized for edge environments:
No Node.js dependencies : Uses only web-standard APIs
Stateless : No session management or persistent connections
Simplified authentication : No built-in OAuth support
No stdio transport : Only HTTP-based protocols
Limited features : No resource templates, completions, or sampling
Deployment Examples
Cloudflare Workers
import { EdgeFastMCP } from "fastmcp/edge" ;
import { z } from "zod" ;
const server = new EdgeFastMCP ({
name: "cloudflare-mcp" ,
version: "1.0.0" ,
});
server . addTool ({
name: "kv_get" ,
description: "Get value from KV" ,
parameters: z . object ({ key: z . string () }),
execute : async ({ key }, env ) => {
const value = await env . MY_KV . get ( key );
return value || "Not found" ;
},
});
export default {
async fetch ( request : Request , env : Env ) : Promise < Response > {
return server . fetch ( request );
} ,
} ;
Deno Deploy
import { EdgeFastMCP } from "npm:fastmcp/edge" ;
const server = new EdgeFastMCP ({
name: "deno-mcp" ,
version: "1.0.0" ,
});
server . addTool ({
name: "env_get" ,
description: "Get environment variable" ,
execute : async ({ key }) => {
return Deno . env . get ( key ) || "Not set" ;
},
});
Deno . serve (( request ) => server . fetch ( request ));
Bun
import { EdgeFastMCP } from "fastmcp/edge" ;
const server = new EdgeFastMCP ({
name: "bun-mcp" ,
version: "1.0.0" ,
});
server . addTool ({
name: "hash" ,
description: "Hash a string" ,
execute : async ({ text }) => {
const hash = Bun . hash ( text );
return hash . toString ();
},
});
Bun . serve ({
fetch : ( request ) => server . fetch ( request ),
port: 8000 ,
});