FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
dthyresson
dthyressonmcp-test
Let's make an easy MCP server using Val Town to use in Cursor
Public
Like
mcp-test
Home
Code
8
data
2
lib
1
server
1
tools
10
.vtignore
README.md
deno.json
H
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
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.
Sign up now
Code
/
Code
/
Search
main.ts
https://dthyresson--1089247a58eb11f093eef69ea79377d9.web.val.run
README.md

Map Info MCP Server

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.


Directory Structure

├── 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

Quick Start

  1. 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.
  2. Test the API

    • Use HTTP tools or MCP-compatible clients to call the server.
  3. Integrate with Cursor

    • See the Using MCP Serve in Cursor section below.

Using MCP Serve in Cursor

  1. Start the MCP Server

    • Ensure your MCP server is running and accessible via a public URL.
  2. 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.
  3. Access in Cursor

    • Open the Command Palette, search for "MCP", and use your registered server.

For more, see Cursor MCP documentation.


How to Add a New Tool

  1. Create a Tool Handler

    • Add a new file in tools/ (e.g., tools/myNewTool.ts).
    • Export a function with the signature:
      Create val
      export function myNewTool(args: { param1: string; }): string | Promise<string> { // Your logic here return "result"; }
  2. Register the Tool

    • In server/mapMcpServer.ts, import your handler:
      Create val
      import { myNewTool } from "../tools/myNewTool.ts";
    • Register it:
      Create val
      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, });
  3. (Optional) Add Data

    • If your tool needs new data, add it to data/ and import as needed.
  4. Test

    • Restart/redeploy the server and call your new tool via the MCP protocol or Cursor.

Example Tools

  • 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.

random_place

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 } }

Error Handling

  • Returns 404 for unknown locations
  • Returns 400 for invalid function names or malformed requests
  • All responses include appropriate HTTP status codes and error messages

Contributing

  • 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.
HTTP
  • main.ts
    dthyresson--10…d9.web.val.run
Code
datalibservertools.vtignoreREADME.mddeno.json
H
main.ts
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.