Skip to main content
Glama

Bun Fun MCP Server

index.ts2.81 kB
#!/usr/bin/env bun import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js"; const server = new Server( { name: "example-mcp-server", version: "1.0.0", }, { capabilities: { tools: {}, }, }, ); server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "get_current_time", description: "Get the current time in ISO format", inputSchema: { type: "object", properties: {}, }, }, { name: "echo", description: "Echo back the provided message", inputSchema: { type: "object", properties: { message: { type: "string", description: "The message to echo back", }, }, required: ["message"], }, }, { name: "add_numbers", description: "Add two numbers together", inputSchema: { type: "object", properties: { a: { type: "number", description: "First number", }, b: { type: "number", description: "Second number", }, }, required: ["a", "b"], }, }, ], }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; switch (name) { case "get_current_time": return { content: [ { type: "text", text: new Date().toISOString(), }, ], }; case "echo": if (!args || typeof args.message !== "string") { throw new Error("Missing or invalid 'message' argument"); } return { content: [ { type: "text", text: `Echo: ${args.message}`, }, ], }; case "add_numbers": if (!args || typeof args.a !== "number" || typeof args.b !== "number") { throw new Error("Missing or invalid number arguments"); } const result = args.a + args.b; return { content: [ { type: "text", text: `${args.a} + ${args.b} = ${result}`, }, ], }; default: throw new Error(`Unknown tool: ${name}`); } }); async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("MCP Server running on stdio"); } main().catch((error) => { console.error("Server error:", error); process.exit(1); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/anthonybaldwin/bun-fun'

If you have feedback or need assistance with the MCP directory API, please join our Discord server