mcp-server-simpsons-cities

mcp-server-simpsons-cities

An MCP server that finds real U.S. cities near a given zip code whose names match anything from The Simpsons.

Category
访问服务器

README

🏘️ mcp-server-simpsons-cities

An MCP (Model Context Protocol) server that finds real U.S. cities near a given zip code whose names match anything from The Simpsons — not just towns like Springfield and Shelbyville, but character names, businesses, and other references from the show. If there's a real town near you called "Maggie," this tool finds it.

Built as an end-to-end MCP integration: a Python server exposing a live tool to Claude Desktop, backed by a real geospatial API and a self-scraped reference dataset.


Why this project

This started as a fun, low-stakes way to explore the full MCP development lifecycle — from writing and debugging a Python server, to authenticating against a third-party API, to wiring it into a real LLM client and iterating based on live tool-call failures. It touches:

  • API integration — authenticated third-party REST API (GeoNames), with real debugging around HTTPS certificate mismatches, auth propagation delays, and rate limits
  • Data engineering — a standalone scraper that paginates a MediaWiki API, dedupes, and filters noisy category data into a clean reference dataset
  • Protocol-level tool design — exposing a single well-scoped tool via FastMCP rather than forcing an LLM client to chain multiple raw API calls itself
  • Environment & secrets management.env-based config, gitignored credentials, environment variables passed cleanly into a subprocess-launched server
  • Client integration & debugging — wiring the server into Claude Desktop's claude_desktop_config.json, and using the MCP Inspector plus stderr logging to diagnose failures that only appeared once the tool was actually called end-to-end

Demo

Live tool call in Claude Desktop (used here as the MCP client) — a natural-language question, routed automatically to the right tool, answered with a live API result:

✅ True positive — a real match found

Claude Desktop finds a real Springfield, IL match for zip code 62701

❌ Correct negative — no match, and Claude proactively offers next steps

Claude Desktop correctly finds no Simpsons-named cities near zip code 92840


Architecture

                    ┌─────────────────────┐
   "Any Simpsons-   │   Claude Desktop     │
    named cities     │   (MCP Client)       │
    near 62701?" ───▶│                       │
                    └──────────┬───────────┘
                               │ MCP protocol (stdio)
                               ▼
                    ┌─────────────────────┐
                    │ find_simpsons_       │
                    │ cities.py            │
                    │  (FastMCP server)    │
                    └──────────┬───────────┘
                               │
                 ┌─────────────┴─────────────┐
                 ▼                             ▼
      ┌────────────────────┐      ┌───────────────────────┐
      │   GeoNames API      │      │  data/simpsons_       │
      │ (nearby cities by   │      │  names.json            │
      │  zip + radius)      │      │  (pre-built, scraped   │
      └────────────────────┘      │  from Wikisimpsons)     │
                                    └───────────────────────┘

Request flow:

  1. User asks a natural-language question in Claude Desktop.
  2. Claude Desktop, acting as the MCP client, recognizes the intent and calls the get_simpsons_city tool over the MCP protocol.
  3. The server queries GeoNames for real cities within a radius of the given zip code.
  4. Each city name is checked (case-insensitively) against a locally-cached Simpsons name database.
  5. Matches — or a clear "no matches" result — are returned to Claude, which formats a natural-language response.

Tools exposed

Tool Description
get_simpsons_city(zipcode, radius_km=30) Finds real cities near a U.S. zip code that share a name with a character, location, or business from The Simpsons.

Tech stack

  • FastMCP (mcp[cli], pinned to v1.x) — MCP server framework
  • httpx — async HTTP client for both the GeoNames API and the Wikisimpsons scraper
  • uv — Python dependency & environment management
  • GeoNames — free geospatial API for zip-code-radius city lookups
  • Wikisimpsons (Fandom) — source data via the MediaWiki categorymembers API
  • Claude Desktop — MCP client used for testing and live usage
  • MCP Inspector — interactive tool-testing UI during development

Getting started

Prerequisites

  • Python 3.13+
  • uv
  • A free GeoNames account with the free web service enabled on your account page — this is a separate step from registering, and easy to miss.

Install

git clone https://github.com/cindyhsugit/mcp-server-simpsons-cities.git
cd mcp-server-simpsons-cities
uv sync

Configure

Create a .env file in the project root:

GEONAMES_USERNAME=your_geonames_username

.env is gitignored — never commit real credentials.

(Optional) Rebuild the Simpsons name database

A pre-built data/simpsons_names.json ships with the repo. To refresh it from Wikisimpsons:

uv run build_data.py

This paginates through Category:Characters, Category:Locations, and Category:Businesses via the Fandom MediaWiki API, dedupes results, and writes a clean JSON list.


Running & testing

Standalone (sanity-check startup):

uv run find_simpsons_cities.py

Interactive testing (requires Node.js):

uv run mcp dev find_simpsons_cities.py

Opens the MCP Inspector in your browser for calling get_simpsons_city directly with real inputs and inspecting raw responses.


Connecting to Claude Desktop

This project was built and tested using Claude Desktop as the MCP client.

Open your config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Add:

{
  "mcpServers": {
    "simpsons-cities": {
      "command": "uv",
      "args": [
        "--directory",
        "/absolute/path/to/mcp-server-simpsons-cities",
        "run",
        "find_simpsons_cities.py"
      ],
      "env": {
        "GEONAMES_USERNAME": "your_geonames_username"
      }
    }
  }
}

Fully quit and reopen Claude Desktop, then just ask:

"Are there any Simpsons-named cities near zip code 62701?"


Project structure

mcp-server-simpsons-cities/
├── find_simpsons_cities.py   # MCP server — defines get_simpsons_city tool
├── build_data.py             # Standalone scraper — builds data/simpsons_names.json
├── data/
│   └── simpsons_names.json   # Scraped Simpsons character/location/business names
├── screenshots/
│   ├── example-match-springfield.png
│   └── example-no-match-92840.png
├── pyproject.toml
├── .env                      # (gitignored) GeoNames credentials
└── README.md

Engineering notes / lessons learned

A few real issues hit and resolved during development, kept here for transparency:

  • mcp v2 breaking change — a new major SDK release renamed FastMCP to MCPServer, silently breaking from mcp.server.fastmcp import FastMCP. Fixed by pinning mcp[cli]>=1.28,<2 in pyproject.toml.
  • GeoNames certificate mismatchhttps://api.geonames.org serves a certificate valid for geonames.net, not .org, causing browser/TLS warnings. Resolved by using plain HTTP for the free-tier endpoint (the pattern GeoNames' own official examples use).
  • GeoNames "premium-only" trapsecure.geonames.org looks like the natural HTTPS alternative, but it's a premium-tier-only endpoint and returns 401 for free accounts.
  • Silent account activation delay — enabling the free web service on a GeoNames account doesn't always propagate instantly; requests can 401 for several minutes after enabling before working.
  • Debuggability — added structured stderr logging in the HTTP layer specifically so failures surface in the MCP Inspector / Claude Desktop's developer log instead of collapsing into a generic error message.

Known limitations

  • 30 km search radius — the free-tier cap on GeoNames' findNearbyPostalCodes endpoint.
  • Exact-match only — a city name must match a Simpsons name exactly (case-insensitive). "Springfield Heights" would not match "Springfield." Fuzzy/substring matching is a natural next step.
  • US zip codes only — scoped to country=US for now.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选