Loading...
Loading...
Loading...
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new McpServer({
name: "my-first-mcp",
version: "1.0.0",
});
// Define a tool
server.tool(
"get_weather",
"Get current weather for a location",
{
location: {
type: "string",
description: "City name or coordinates",
},
},
async ({ location }) => {
// Your implementation here
return {
content: [
{
type: "text",
text: `Weather for ${location}: 72°F, Sunny`,
},
],
};
}
);
// Start the server
const transport = new StdioServerTransport();
await server.connect(transport);