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.
main.ts
https://dthyresson--1089247a58eb11f093eef69ea79377d9.web.val.run
A Model Context Protocol (MCP) server for map and location information, designed for extensibility and easy integration with MCP-compatible clients and tools like Cursor.
├── data/
│ ├── nearby.ts # Data for nearby places
│ └── places.ts # Data for known locations
├── lib/
│ └── mcpServer.ts # Core MCP server class and types
├── server/
│ └── mapMcpServer.ts # MCP server instance and tool registration
├── tools/
│ ├── getCoordinates.ts # Tool: get_coordinates handler
│ └── getNearbyPlaces.ts# Tool: get_nearby_places handler
├── main.ts # Entry point (exports MCP server fetch handler)
├── README.md # Project documentation
-
Deploy or Run the Server
- Deploy to Val Town or run locally (ensure public URL for Cursor integration).
- The entry point is
main.ts
which exports the MCP server's fetch handler.
-
Test the API
- Use HTTP tools or MCP-compatible clients to call the server.
-
Integrate with Cursor
- See the Using MCP Serve in Cursor section below.
-
Start the MCP Server
- Ensure your MCP server is running and accessible via a public URL.
-
Configure Cursor
- Edit or create
~/.cursor/mcp.json
:{ "mcpServers": { "dt-mcp": { "url": "https://your-mcp-server-url" } } } - Replace the URL with your MCP server's endpoint.
- Edit or create
-
Access in Cursor
- Open the Command Palette, search for "MCP", and use your registered server.
For more, see Cursor MCP documentation.
-
Create a Tool Handler
- Add a new file in
tools/
(e.g.,tools/myNewTool.ts
). - Export a function with the signature:
export function myNewTool(args: { param1: string; }): string | Promise<string> { // Your logic here return "result"; }
- Add a new file in
-
Register the Tool
- In
server/mapMcpServer.ts
, import your handler: - Register it:
mapMcpServer.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/
and import as needed.
- If your tool needs new data, add it to
-
Test
- Restart/redeploy the server and call your new tool via the MCP protocol or Cursor.
- get_coordinates: Returns coordinates for a named location.
- get_nearby_places: Returns a list of places near a given location.
- random_place: Returns a random place from the known locations.
Returns a random place from the available locations.
Parameters:
- None
Example Request:
{ "name": "random_place", "input": {} }
Example Response:
{ "output": { "name": "Eiffel Tower", "lat": 48.8584, "lng": 2.2945 } }
- Returns 404 for unknown locations
- Returns 400 for invalid function names or malformed requests
- All responses include appropriate HTTP status codes and error messages
- Follow the directory structure for new tools and data.
- Keep tool logic modular (one file per tool in
tools/
). - Update this README with new features or tools.
- For questions or contributions, see code comments or open an issue.