NMAH Military Collection MCP
Provides read-only tools for searching the Smithsonian Open Access NMAH Armed Forces History collections, retrieving object metadata, and listing image assets with usage rights.
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., "@NMAH Military Collection MCP search NMAH military objects for WWII Navy uniforms with images"
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.
NMAH Military Collection MCP
An independent, read-only Model Context Protocol (MCP) server and local Playground for exploring the Armed Forces History collections at the National Museum of American History (NMAH). Search catalog records, retrieve full object metadata, and check image sources and usage rights through Smithsonian Open Access.
Quick Start
Install Python 3.13 or newer and uv. Clone the repository and start the Playground:
git clone https://github.com/yixuan-liu/nmah-military-collection-mcp.git
cd nmah-military-collection-mcp
uv run --locked python playground/server.pyOpen the local URL printed in the terminal.
Select Set API key, enter your Smithsonian Open Access key, and choose Verify and apply. After the first successful verification, choose Continue to search. Get a key from the Smithsonian EDAN signup form. Tool schemas are available before you configure a key.
Search for
nmah_446333and select Inspect. Choose Metadata or Image assets and press Enter to run the selected lookup. Try both modes with the same record ID to compare the results.
If you keep a key in the project's ignored .env, start the Playground with:
uv run --locked --env-file .env python playground/server.pyRelated MCP server: Smithsonian MCP Server
MCP tools
Tool | What it does |
| Search the NMAH Armed Forces History collection scope by keyword, with optional branch, decade, and image filters. Results include pagination information. |
| Verify the collection scope and return the full Smithsonian record for an NMAH record ID. |
| List available Open Access JPEG and TIFF resources and IIIF images, with dimensions and usage information where supplied. |
See the tool reference for parameters and examples.
Local Playground
Search the collection and page through results. Use Inspect to carry an NMAH record ID into the record lookup.
Review metadata and image resources in separate panels. Open IIIF images in a new tab or choose an available Open Access JPEG or TIFF from the preview dialog.
View tool schemas, applied search filters, and raw JSON responses. Copy a request ID to find the corresponding Playground and MCP logs.
The Playground listens on loopback. A key verified in the browser stays in memory for that local process and is shared across its tabs. Use project default restores the key loaded when the Playground started. If no key was loaded at startup, the Playground returns to an unconfigured state. Press Ctrl+C in the terminal to stop the process.
Setup and startup
To use the MCP server from a client, install the locked dependencies and set
SMITHSONIAN_API_KEY in the project's ignored .env. If a .env already
exists, use that file.
uv sync --locked
cp -n .env.example .envThe environment template lists the supported variables. The
MCP server authenticates upstream requests with the X-Api-Key header.
Connect an MCP client
After uv sync --locked, keep your key in the clone's ignored .env. In the
examples below, replace both paths with absolute paths to your copy of uv and
your clone. Merge the server entry into your existing client configuration.
Codex (~/.codex/config.toml)
[mcp_servers.nmah-military-collection]
command = "/absolute/path/to/uv"
args = ["run", "--locked", "--directory", "/absolute/path/to/nmah-military-collection-mcp", "--env-file", ".env", "python", "-m", "nmah_military_collection_mcp"]Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"nmah-military-collection": {
"command": "/absolute/path/to/uv",
"args": [
"run",
"--locked",
"--directory",
"/absolute/path/to/nmah-military-collection-mcp",
"--env-file",
".env",
"python",
"-m",
"nmah_military_collection_mcp"
]
}
}
}Restart the client. In Codex, use codex mcp list to confirm registration.
Then check tool discovery and ask the client to find nmah_446333 with
search_nmah_military_objects.
Logging
Set LOG_LEVEL=INFO in the root .env to control application logs for both
the MCP server and the Playground. Use either startup command with
--env-file .env, and restart after changing the value. If an MCP client
starts the server, use that same launch option or supply LOG_LEVEL in
the client's environment. The Playground forwards the setting to its MCP
subprocess.
INFO is the default for unset, blank, or invalid values. Use DEBUG for
upstream request timing and pagination details, or WARNING, ERROR, or
CRITICAL for quieter output. Application logs go to stderr. MCP stdout
carries protocol messages. Set FASTMCP_LOG_LEVEL separately to change
FastMCP framework logging. Application logs omit credentials, request
headers, search text, full request URLs, and response bodies.
Tool reference
Search objects
Parameter | Default | Behavior |
| Empty string | Keyword expression. Empty or whitespace-only input becomes |
|
| Army, Navy, Air Force, Marine Corps, or Coast Guard. |
|
| Page size from 1 to 50. |
|
| Non-negative starting position, passed as API |
|
| One decade label from |
|
| When true, adds |
{
"query": "cap",
"branch": "Army",
"date": "1910s",
"has_images": true,
"rows": 10,
"offset": 0
}Object names, models, people, and other descriptive terms go in query.
The fixed fqs include unit_code:NMAH, type:edanmdm, and the escaped
Military and Society: Armed Forces History set-name prefix. Filters are sent
as a JSON array encoded into the API's fqs parameter. Sorting uses id.
Branch matching checks title and object_type, ignoring case. The aliases
USA, USN, USAF, USAAF, USMC, USCG, WAC, WAAC, USNR,
U.S.N., U.S.C.G., U.S.M.C., and Marine require boundaries at field edges
or characters outside ASCII letters, digits, and underscore. Dots in aliases
are matched literally. Other aliases use substring matching. Army also includes
Military Academy. Navy also includes Naval Academy, Midshipman, and
Naval Reserve. Air Force also includes Army Air Forces and Air Corps. These are overlapping research groups. Preserve historical names
and verify attribution against the original record.
Date filtering matches the catalog's indexed decade labels. A record can have multiple labels, and the indexed date may describe an association rather than manufacture. Image indexing can exist without an image URL in the API response.
Retrieve object metadata
Call get_nmah_military_object_metadata with a bare NMAH record ID:
{
"record_id": "nmah_463569"
}Use content.descriptiveNonRepeating.record_ID from a search result. This
required string accepts nmah_ followed by digits (maximum 64 characters),
not the top-level row ID, a catalog number, or a URL.
The tool requests /content/edanmdm%3A{record_id} with header authentication.
It checks the returned record ID, NMAH unit codes, edanmdm type, and an
Armed Forces History set-name prefix before returning the entire API
response record unchanged. This includes the content metadata and all
other record fields; the API transport envelope is not included.
Out-of-scope, missing, or unverifiable records return a tool error.
No image filter is applied. Image URLs may be absent; no IIIF fallback,
summary, or rights inference is added.
List image assets
Call get_nmah_military_object_image_assets with a bare record_id, such as
nmah_446333 or nmah_463569. The tool verifies the same collection scope as
metadata retrieval. It lists high-resolution Open Access JPEG and TIFF resources
first and checks the public Smithsonian IIIF Presentation 2 manifest for matching
or additional views. It groups resources by media ID when one can be established.
Dimensions describe the listed resource and come from its source.
The media_access field preserves the individual image's Open Access
usage.access value or null when unavailable. The usage_label is CC0
only when the image's own access value is CC0. All other values display
Usage Conditions Apply. The manifest license URL is reported separately.
Status | Meaning |
| Source checks completed and found at least one resource. |
| A source could not be checked fully. The tool returns any resources already found and explains the gap in |
| Source checks completed without finding a supported resource. |
In the Playground, use View image to choose an available Open Access JPEG or TIFF, or to open an IIIF image in a new tab.
Results and pagination
The search response contains total_count, returned, offset, next_offset, the
applied query and filters, selected options, candidate aliases, and raw API
records in objects. Candidate aliases describe the search configuration.
Keep the same search arguments and use next_offset for the next call when it
is set. If next_offset is null, compare offset + returned with
total_count. A value at or beyond total_count indicates the end of the
reported results. If returned is zero and offset < total_count, treat
the empty page as an upstream anomaly and the results as incomplete. Offset
pagination reflects the current upstream index.
Architecture
The browser uses local HTTP to reach the Python bridge. The bridge calls the MCP server over stdio. Codex and Claude Desktop can launch the same MCP server directly using the client configuration.
flowchart LR
Browser["Local Playground in the browser"] -->|Local HTTP| Bridge["Python bridge"]
Bridge -->|MCP over stdio| MCP["NMAH MCP server"]
Client["Codex or Claude Desktop"] -->|MCP over stdio| MCP
MCP -->|HTTPS| OpenAccess["Smithsonian Open Access API"]
MCP -->|HTTPS| IIIF["Smithsonian IIIF and Image Delivery Service"]
Bridge -->|HTTPS for key verification| OpenAccess
Bridge -->|HTTPS for image delivery| IIIFThe installed MCP package lives under src/nmah_military_collection_mcp/.
The Playground uses native JavaScript modules served by the Python bridge.
See the architecture guide for the tool call flows.
Module | Responsibility |
| Register tools and manage one shared HTTP client per server lifespan. |
| Define the MCP interface and orchestrate search and metadata retrieval. |
| Build the search request and verify collection membership on retrieved records. |
| Read credentials on demand, send requests, and validate response envelopes. |
| Share search types and report failures across modules. |
Tool discovery works without an API key.
Verification
Run the local checks from the project root after uv sync --locked.
uv run --locked fastmcp inspect src/nmah_military_collection_mcp/server.py --format mcp
uv run --locked ruff check src tests playground
uv run --locked ruff format --check src tests playground
uv run --locked python -m unittest discover -s tests
uv run --locked python tests/smoke.pyRuff checks Python files under src/, tests/, and playground/. To apply safe lint fixes,
including import sorting, and format the files, run:
uv run --locked ruff check --fix src tests playground
uv run --locked ruff format src tests playgroundRun the live comparison separately with a Smithsonian API key:
uv run --locked --env-file .env python tests/smoke.py --liveThe unit tests check alias matching, HTTP requests with an injected mock transport, connection cleanup, and metadata scope and failure handling. The metadata fixture is a copy of the saved Smithsonian content response. The stdio smoke check verifies discovery, schemas, instructions, and input validation. Live mode compares search rows and counts and the complete metadata record with direct Open Access API responses. It also checks the image tool against an Open Access JPEG case and an IIIF fallback case.
Documentation
Project guides · English and 中文. Both indexes cover architecture, search, images, logging, and verification.
Smithsonian API reference · Official Open Access documentation and unofficial Swagger UI.
License
Original project code and documentation are available under the MIT License. See third-party notices for Swagger UI and Smithsonian materials.
Available Tools
3 toolsget_nmah_military_object_image_assetsGet Nmah Military Object Image AssetsARead-only
List official JPEG and TIFF resources for one NMAH military object.
Verify the collection scope, inspect Open Access media, and check the public IIIF manifest for additional views or fallback resources. Rights are reported per image from its own usage.access. Missing access is reported as null and displayed as Usage Conditions Apply. Status partial means a discovery source could not be fully checked. Dimensions are source declarations.
Inputs: record_id (required). Returns: images, status, warnings, record_id, +2 more
get_nmah_military_object_metadataGet Nmah Military Object MetadataARead-only
Retrieve the complete museum metadata record for one NMAH military object.
Verify NMAH ownership and the Armed Forces History set-name prefix before returning the unmodified content endpoint response record. Out-of-scope, missing, or unverifiable records produce a tool error. No fields are summarized or removed, and no IIIF or other sources are added.
Inputs: record_id (required). Returns: object
search_nmah_military_objectsSearch Nmah Military ObjectsCRead-only
Search National Museum of American History (NMAH) objects within the "Military and Society: Armed Forces History" set-name prefix.
Inputs: date, rows, query, branch, +2 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a distinct action and output: search returns matching objects, metadata returns a full record for one object, and image assets returns media resources for one object. The boundaries are clear, and the descriptions reinforce when to use each tool.
All three tools use consistent snake_case with a predictable verb_noun structure and a shared nmah_military_object(s) domain prefix. The pattern is easy to parse despite the long names.
Three tools are well-scoped for a narrow read-only museum collection server: discover objects, inspect metadata, and retrieve image assets. Each tool earns its place, and there is no redundant surface area.
The server covers the core read-only lifecycle for military collection objects: search, full metadata retrieval, and image asset discovery. Minor gaps exist, such as no explicit collection/set listing or alternate lookup by accession number, but the core workflows are covered.
Maintenance
Related MCP Connectors
Search 14.5M Smithsonian Open Access objects, get CC0 images, find cross-collection connections.
Search the Met collection, browse by department or update date, fetch full records and CC0 images.
Access US federal award, recipient, agency, and spending analytics data from USAspending.gov.
Search 618,000+ public domain paintings, prints and drawings from 73 museums and libraries.
Related MCP Servers
- AlicenseAqualityBmaintenanceProvides AI assistants with access to search, explore, and analyze over 3 million collection objects from the Smithsonian Institution's museums. Enables finding objects currently on exhibit, retrieving detailed metadata, high-resolution images, and 3D models from America's national museums.5146 npm10MIT
- AlicenseNot gradedqualityDmaintenanceEnables searching and exploring millions of items from the Smithsonian Institution's collections including artifacts, artworks, specimens, photographs, and more, using the Smithsonian Open Access API.3MIT
- AlicenseNot gradedqualityCmaintenanceEnables searching and retrieving detailed information about items from the Smithsonian Open Access collection, including metadata and images.86 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables searching 14.5M Smithsonian Open Access objects, retrieving CC0 images, and exploring museum collections via MCP with 6 tools.145 npm2Apache 2.0