mcp-town-explorer
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-town-explorerCompare schools in Winchester and Lexington"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-town-explorer
A learning project that makes every MCP boundary visible: host, client, server, transport, discovery, invocation. The trick that makes the boundaries legible is one server, two hosts: a no-LLM host and an LLM host talk to the exact same server with zero server changes.
What MCP is
The Model Context Protocol (MCP) is a standard way for an application (the host) to let a language model use external tools and data through a uniform interface. The host embeds an MCP client that speaks JSON-RPC to one or more MCP servers; each server advertises tools (callable functions) and resources (readable content) with machine-readable schemas. The point is decoupling: any MCP-speaking host can use any MCP server without custom glue, because discovery ("what tools exist?") and invocation ("call this tool with these arguments") are standardized.
Related MCP server: Contract Review Demo MCP Server
Architecture
Which file is which:
Host:
v1_cli/host.pyandv2_llm/host.py. The host owns the user interaction, and in V2 owns the LLM and the validation logic.Client:
ClientSessionfrom the MCP SDK, constructed inside each host. It is not hand-written JSON-RPC; the SDK provides it.Server:
server/server.py. Built with FastMCP; exposes the tools and resource. Neither host imports it -- they only launch it as a subprocess and speak the protocol.
For a deeper walk-through of the MCP plumbing (transport, client, handshake, schemas, result shapes), see docs/notes.md.
Setup
Uses uv. Python is pinned to 3.12.
uv syncRun V1 (no LLM, no API key)
Argv selects the tool; the model is never involved. This isolates the protocol from model behavior.
uv run python v1_cli/host.py list-tools # print the raw advertised JSON schema
uv run python v1_cli/host.py housing Winchester
uv run python v1_cli/host.py distance Winchester
uv run python v1_cli/host.py schools Lexington
uv run python v1_cli/host.py safety Woburn
uv run python v1_cli/host.py resource Winchester # read the town://{town} resource
uv run python v1_cli/host.py --verbose housing Winchester # log the protocol lifecycleThe error path, deliberately shown:
uv run python v1_cli/host.py housing Nowhere
# -> ERROR from server: Unknown town: 'Nowhere'. Known towns: ...
# exits non-zero; the server error surfaces across the protocol rather than being swallowedRun V2 (adds the LLM)
Natural language in. The model sees the tool schemas, proposes a call, the host validates it, the client executes it, the result is fed back, and the model explains. The loop repeats (capped at 5 iterations) until the model stops requesting tools.
Put OPENAI_API_KEY in a .env file at the repo root (it is git-ignored); the
host loads it automatically via python-dotenv. Exporting the variable works too.
# .env at the repo root contains: OPENAI_API_KEY=sk-... (loaded automatically)
uv run python v2_llm/host.py "Compare schools in Winchester and Lexington"
uv run python v2_llm/host.py --show-tokens "How safe is Woburn?" # print tool-schema token cost
# or export it instead of using .env:
export OPENAI_API_KEY=sk-...
uv run python v2_llm/host.py "How safe is Woburn?"The validation step is the reason V2 exists.
Before any execution the host checks the proposed tool name against an allowlist and, for tools that take a town, checks that the town exists in the dataset; a rejected call is logged ([REJECTED] ...) and never reaches the server.
The exact line where a model proposal becomes an execution is commented in v2_llm/host.py.
Provenance
This dataset describes real Massachusetts towns, but it is stitched together from several sources of differing years and methodologies. It is a demo for teaching MCP architecture. Do not use it for any real decision (buying a home, choosing a school district, judging safety).
Sources, one per column:
column | source |
| Zillow Home Value Index (ZHVI), town level |
| GreatSchools, rounded average of the town's public schools (GreatSchools publishes no single district number) |
| NeighborhoodScout, incidents per 1,000 (2024 FBI-derived vintage) |
| computed: haversine from the town's US Census/Wikipedia centroid to Boston City Hall (42.3601, -71.0589) |
| US Census (2020 decennial or ACS estimate) |
Per-column source URLs, vintages, retrieval notes, and known caveats are recorded in PROVENANCE.md.
The habit is the lesson: record where every number came from, even in a teaching dataset.
What this does NOT demonstrate
Deployment. stdio transport means the server is a local subprocess the host spawns. There is no network service, no container, no host/port.
Auth. No authentication or authorization between host and server. The V2 "permission boundary" is application-level input validation, not identity or access control.
Remote transport. No HTTP/SSE/streamable transport. Everything is local stdio.
Multi-user / concurrency. One host, one server subprocess, one user, one request at a time.
Available Tools
4 toolsget_distanceC
Straight-line distance from one town to Boston, in miles.
| Name | Required | Description | Default |
|---|---|---|---|
| town | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It doesn't state what happens for unknown towns, whether the distance is a great-circle/straight-line approximation (beyond the word 'straight-line'), whether output is rounded, or the return format. Positioned as a pure read function, but details are sparse.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One concise sentence with zero wasted words. It packs the verb, resource, measurement type, and destination into a minimal, scannable format.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter tool with no output schema and no annotations, the description is thin. It doesn't specify the return unit/format, behavior for invalid input, or how it integrates with sibling tools. While simple, it lacks the behavioral details an agent needs to confidently use it.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It explains 'town' is one town (singular) and that distance is measured to Boston, which adds semantic context. However, it doesn't clarify whether the town name must be a specific canonical form, match sibling tool conventions, or examples of valid values.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('get'), resource ('distance'), and scope ('straight-line distance from one town to Boston'), defining a specific, measurable output. It's distinguishable from siblings (get_housing, get_schools, get_safety) which focus on location features rather than distance.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives. It doesn't explain use cases like comparing town proximity or filtering by distance, nor does it exclude any scenarios. The description implies a simple distance lookup but offers no context for when it would be relevant.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_housingB
Median home price for one town, in USD.
| Name | Required | Description | Default |
|---|---|---|---|
| town | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It confirms this is a read operation (getting median home price), but doesn't disclose data freshness, what time period the median reflects, potential missing-data behavior, or whether the price reflects current listings vs sold values. Without annotations, more behavioral context would be expected.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, extremely efficient - 'Median home price for one town, in USD.' covers purpose, scope, and unit with zero wasted words. No redundancy with the name or schema.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple single-parameter read tool, the description is mostly adequate. There is no output schema, no annotations, and 0% schema coverage, so the description carries the entire burden. It tells the agent the return value conceptually (median home price in USD) but leaves uncertainty about date range, data recency, and edge cases. Given the simplicity of the tool, this is near-minimum-viable but has noticeable gaps.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There is one parameter (town) with 0% schema description coverage, meaning the schema property has no description beyond its name. The description states the town is a single town (scope), which adds some meaning, but doesn't clarify expected format (e.g., 'Springfield, MA' vs 'springfield'), case sensitivity, or valid range of town names. With only one param, the baseline credit is partially earned but minimal guidance is given.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Median home price for one town, in USD' clearly states the verb+resource (get median home price) and adds the scope constraint 'one town'. It distinguishes from siblings like get_distance, get_schools, get_safety which cover different domains. However, it doesn't explicitly name the alternative tools, slightly limiting differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage in the context of querying housing cost data for a single town, and the sibling tool names (get_distance, get_schools, get_safety) suggest the broader context of town comparison. However, there are no explicit when-to-use or when-not-to-use instructions, nor any exclusions or alternatives named.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_safetyB
Crime figures for one town: violent crime rate as incidents per 1,000 residents.
| Name | Required | Description | Default |
|---|---|---|---|
| town | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided at all, so the description carries the full burden of behavioral disclosure. The description states the metric and unit (violent crime rate per 1,000 residents), which is useful, but it does not disclose what happens for unknown towns, whether the data is recent, whether it includes other crime types beyond violent crime, or the reliability/source of figures. For a data-query tool with zero annotation coverage, the behavioral context is thin.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One crisp sentence, front-loaded with the action and resource, then the unit detail. Zero waste, all content earns its place. This is an example of effective conciseness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (one parameter, no output schema, no nested objects), the description is fairly complete for the core purpose. However, with no annotations and no output schema, the agent gets no information about response format, error handling for invalid towns, or data vintage. For a simple tool the bar is lower, but the absence of any behavior-disclosure given zero annotation coverage leaves it at 'adequate but with gaps'.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, and the only parameter (town) has no description. Both the description and schema leave 'town' interpretation entirely to the agent. However, the description clarifies that the result is per-1000-residents violent crime rate, which adds meaning about the tool's output framing. Since there is only one obvious parameter whose semantics are inferable from the tool name and description, the gap is minimal — but a note on town name format would help.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb+resource ('Get crime figures for one town') and the scope is clear — it provides a specific metric (violent crime rate per 1,000 residents). It distinguishes from siblings by focusing on safety/crime data for a town, though it doesn't explicitly contrast with get_schools, get_housing, etc. The resource and metric are clear but the sibling differentiation is implicit rather than explicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage (query crime figures for a single town), but doesn't state when to use this vs alternatives, nor does it mention limitations like 'only handles one town at a time' or exclude scenarios. It doesn't say when NOT to use it or point to a sibling for related data. The context signal of a single required 'town' parameter makes usage somewhat self-evident, but explicit guidance on vs-alternatives is absent.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_schoolsB
School rating for one town (GreatSchools district rating, 1-10).
| Name | Required | Description | Default |
|---|---|---|---|
| town | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, leaving the description to carry the disclosure burden. It does disclose the rating scale (1-10) and source (GreatSchools district rating). However, it doesn't say whether this is a read operation, what happens with invalid town names, or whether it returns per-school or district-level data. Some useful context, but gaps remain.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single compact sentence with zero wasted words. The parenthetical adds the scale and source detail efficiently. Appropriate length for a simple one-parameter tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple one-parameter look-up tool, this is near-adequate. No output schema exists, so the description doesn't explain the return format, but for a rating lookup the '1-10' scale disclosure helps. It could clarify whether output is a single number or a breakdown, but for this complexity level it's reasonably complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 0% schema description coverage, the description must compensate. The lone parameter 'town' is a string and its meaning is self-evident from the description's 'one town' phrasing. The description confirms the town parameter scope but adds little beyond what the parameter name implies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a clear verb+resource+scope: 'School rating for one town' with a specific metric (GreatSchools district rating, 1-10). It's distinguishable from siblings (get_housing, get_distance, get_safety) which cover different domains. The parenthetical adds precision about what kind of rating and its scale.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies this returns school ratings scoped to a single town, contrasting with broader alternatives. However, it doesn't explicitly state when to use this vs alternatives or exclude other use cases. The 'one town' scoping is the only guidance, which is modest but helpful.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.1.0- First observed
get_distance - First observed
get_housing - First observed
get_safety - First observed
get_schools
TDQS
Scored across 4 tools
Each tool targets a distinct domain dimension: housing, transportation, education, and public safety. There is no overlap between the four tools, and their purposes are clearly separable by the resource type they query.
All tools follow a consistent get_[noun] pattern (get_housing, get_distance, get_schools, get_safety). The only minor deviation is that 'distance' refers to a relationship (distance to Boston) while the others refer to town attributes, but the naming is otherwise uniform and predictable.
Four tools is a borderline-low count. For a town explorer covering four quality-of-life dimensions (housing, commute, schools, safety), it's coherent but thin—a full explorer might also include taxes, weather, demographics, or amenities.
The four tools cover major town-comparison dimensions (housing, distance, schools, crime), but several obvious gaps exist: no property-tax data, no median income, no demographics or unemployment figures. An agent comparing towns would likely need more than these four metrics for a thorough assessment.
Maintenance
Related MCP Connectors
An MCP server for deep research or task groups
Read-only MCP server for Sandwich aging-parent care resources and cost data.
Related MCP Servers
- FlicenseCqualityDmaintenanceA demo MCP server with tools for getting weather via wttr.in and executing read-only SQLite queries.10-
- AlicenseNot gradedqualityCmaintenanceA public-safe demo MCP server for learning how to package Tools, Resources, and Prompts, using fictional contract text and local demo rules only.MIT
- FlicenseCqualityCmaintenanceA simple MCP server demonstrating resources, tools, and prompts using a local task list. It enables reading, creating, and analyzing tasks through MCP.1-
- AlicenseNot gradedqualityCmaintenanceA demonstration MCP server that enables read-only SQL queries and schema exploration of a synthetic IaaS database through the Metabase API.MIT