Public
Like
mcp-test
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v30View latest version
A Model Context Protocol (MCP) server that provides basic map and location information services.
- Get Coordinates: Retrieve latitude and longitude for named locations
- Get Nearby Places: Find points of interest near a specified location
Currently supports the following locations:
- Eiffel Tower (Paris)
- Central Park (New York)
- Statue of Liberty (New York)
GET /- Health check endpointGET /mcp- MCP service statusGET /mcp/manifest- MCP function manifestPOST /mcp/execute- Execute MCP functions
GET /openapi.yaml- OpenAPI specificationGET /.well-known/ai-plugin.json- AI plugin manifest
Get the coordinates for a named location.
Parameters:
place(string, required): The name of the location
Example Request:
{ "name": "get_coordinates", "input": { "place": "eiffel tower" } }
Example Response:
{ "output": { "lat": 48.8584, "lng": 2.2945 } }
Return a list of nearby places of interest.
Parameters:
place(string, required): The place to find nearby locations from
Example Request:
{ "name": "get_nearby_places", "input": { "place": "central park" } }
Example Response:
{ "output": [ { "name": "The Met", "lat": 40.7794, "lng": -73.9632 }, { "name": "American Museum of Natural History", "lat": 40.7813, "lng": -73.9735 } ] }
This MCP server can be integrated with MCP-compatible clients to provide location-based information services.
- Returns 404 for unknown locations
- Returns 400 for invalid function names or malformed requests
- All responses include appropriate HTTP status codes and error messages
This MCP server is organized for modularity and easy extensibility:
main.ts: Entry point. Exports the MCP server's fetch handler.mcpInstance.ts: Instantiates the MCP server, registers all tools, and exports the fetch handler.mcpServer.ts: Defines theMCPServerclass and types for tool registration and routing.data.ts: Contains the data for places and nearby locations.getCoordinates.ts: Implements the handler for theget_coordinatestool.getNearbyPlaces.ts: Implements the handler for theget_nearby_placestool.
Each tool handler is implemented in its own file for clarity and separation of concerns.
-
Create the Tool Handler
- Add a new file (e.g.,
myNewTool.ts). - Export a function that matches the handler signature:
export function myNewTool(args: { param1: string; }): string | Promise<string> { // Your logic here return "result"; }
- Add a new file (e.g.,
-
Register the Tool
- In
mcpInstance.ts, import your handler: - Register the tool with the server:
mcpServer.registerTool({ name: "my_new_tool", description: "Describe what your tool does", inputSchema: { type: "object", properties: { param1: { type: "string", description: "Description of param1" }, }, required: ["param1"], }, handler: myNewTool, });
- In
-
(Optional) Add Data
- If your tool needs new data, add it to
data.tsand import as needed.
- If your tool needs new data, add it to
-
Test
- Restart the server and call your new tool via the MCP protocol.
For questions or contributions, see the code comments or open an issue.