Created
May 7, 2026 13:32
-
-
Save jonathanbossenger/34f1108e653c0e5231bd66dbd024f47d to your computer and use it in GitHub Desktop.
minimal-mcp-server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; | |
| import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; | |
| import { z } from "zod"; | |
| // Create an MCP server | |
| const server = new McpServer({ | |
| name: "My Support Server", | |
| version: "1.0.0", | |
| }); | |
| // Add a tool | |
| server.registerTool( | |
| "check_site_status", | |
| { | |
| description: "Check if a WordPress site is responding.", | |
| inputSchema: { | |
| url: z.string().url().describe("The URL of the site to check"), | |
| }, | |
| }, | |
| async ({ url }) => { | |
| try { | |
| const response = await fetch(url, { signal: AbortSignal.timeout(10000) }); | |
| return { | |
| content: [ | |
| { | |
| type: "text", | |
| text: `Site ${url} is UP (status: ${response.status})`, | |
| }, | |
| ], | |
| }; | |
| } catch (error) { | |
| return { | |
| content: [ | |
| { | |
| type: "text", | |
| text: `Site ${url} is DOWN: ${(error as Error).message}`, | |
| }, | |
| ], | |
| isError: true, | |
| }; | |
| } | |
| } | |
| ); | |
| // Connect to stdio transport | |
| const transport = new StdioServerTransport(); | |
| await server.connect(transport); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment