main.ts•1.17 kB
#!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { registerPlacesTools } from "./tools/index.js";
// Create MCP server
const server = new McpServer({
name: "google-places-mcp",
version: "1.0.0",
capabilities: {
tools: {},
},
});
// Register tools
registerPlacesTools(server);
// Check required environment variables
const apiKey = process.env.GOOGLE_MAPS_API_KEY;
if (!apiKey) {
console.error("Error: GOOGLE_MAPS_API_KEY environment variable is required");
process.exit(1);
}
// Create stdio transport
const transport = new StdioServerTransport();
// Start server
async function startServer() {
try {
console.error("Starting Google Places MCP Server...");
// Safely handle apiKey logging
if (apiKey) {
console.error(`API Key configured: ${apiKey.substring(0, 10)}...`);
}
await server.connect(transport);
console.error("Google Places MCP Server connected successfully");
} catch (error) {
console.error("Failed to start server:", error);
process.exit(1);
}
}
startServer();