Skip to main content
Glama

Statesman Model Context Protocol (MCP) Server

TypeScript Model Context Protocol License: MIT

A production-ready Model Context Protocol (MCP) server interfacing with the Statesman computational laboratory for comparative geopolitics, statecraft, and urban power centers (/api/v1 REST API).

Statesman MCP allows AI agents (in Antigravity, Claude Desktop, Cursor, and custom agent harnesses) to seamlessly navigate, search, cluster, and synthesize cross-continental geopolitical catalogs, 1024-dimensional pgvector cosine distance manifolds, and multi-stage LLM synthesis monographs.


Capabilities Overview

                      +---------------------------------------+
                      | AI Agent (Claude, Antigravity, etc.)  |
                      +-------------------+-------------------+
                                          |
                                    stdio | JSON-RPC
                                          v
                      +---------------------------------------+
                      |       Statesman MCP Server            |
                      |   - 51 Tools (Search, CRUD, ML)       |
                      |   - 4 Resources (Status, Reports)     |
                      |   - 2 Geopolitical Analysis Prompts   |
                      +-------------------+-------------------+
                                          |
                                     HTTP | REST (/api/v1)
                                          v
                      +---------------------------------------+
                      |         Statesman API (Rails)         |
                      |   - pgvector 1024-dim Manifold        |
                      |   - Connected-Components Clustering   |
                      |   - Multi-phase Synthesis Engine      |
                      +---------------------------------------+

1. Global Search & Manifold Traversal

  • search: Unified semantic (pgvector) or keyword search across sovereign countries and strategic cities.

  • find_counterparts: Identifies nearest structural geopolitical or urban counterparts to any country or city using 1024-dimensional vector cosine distance (with optional continent or country scoping).

2. Geopolitical & Urban Catalog Management (CRUD)

  • Continents (8 tools): list_continents, get_continent, create_continent, update_continent, delete_continent, upsert_continents_batch, populate_continents, populate_continent_countries.

  • Countries (9 tools): list_countries, get_country, create_country, update_country, delete_country, upsert_countries_batch, generate_country_embedding, populate_country_cities, populate_countries_bulk.

  • Cities (8 tools): list_cities, get_city, create_city, update_city, delete_city, upsert_cities_batch, generate_city_embedding, populate_cities_bulk.

3. Archetype Clustering & Snapshots (7 tools)

  • compute_clusters: Dynamically calculates connected-components vector clusters across Country or City manifolds with configurable granularity levels (1–15) and zero-singleton full_coverage absorption without modifying the database.

  • create_cluster_snapshot: Computes and freezes clustering into an immutable database snapshot.

  • list_cluster_snapshots, get_cluster_snapshot, delete_cluster_snapshot, list_cluster_groups, get_cluster_group.

4. Scholarly Synthesis Monograph Reports (9 tools)

  • create_cluster_report: Triggers a 2-Phase Map-Reduce synthesis report on a snapshot with a custom geopolitical or urban research inquiry.

  • generate_deep_synthesis: Initiates a 3-Phase Hierarchical Deep Synthesis monograph, grouping Phase 1 summaries into intermediate batch analyses.

  • list_cluster_reports, get_cluster_report, delete_cluster_report, list_report_summaries, get_report_summary, list_report_sub_reports, get_report_sub_report.

5. Background Jobs & Execution Control (3 tools)

  • get_job_status, list_jobs: Inspect ActiveJob/Sidekiq lifecycle states.

  • wait_for_job: Polls asynchronous operations until completion or failure with configurable intervals and timeouts.

6. System & Settings (5 tools)

  • get_platform_status: Platform health, entity counts (continents, countries, cities), embedding coverage stats, and active LLM configuration.

  • get_settings, update_context_window, trigger_bulk_embeddings, get_openapi_spec.


Related MCP server: knowledge-base-server

MCP Resources

Directly inspectable URIs that AI agents can mount into context:

  • statesman://status: Platform health, entity metrics, and active LLM/embedding models.

  • statesman://continents: Catalog overview of all registered continents and sovereign country counts.

  • statesman://snapshots/{id}: Detailed cluster groups and member states/cities of a frozen snapshot.

  • statesman://reports/{id}: Full compiled markdown text of a scholarly synthesis monograph.


Comparative Geopolitics Prompts

  • comparative_statecraft_analysis: Structured inquiry comparing two sovereign countries or strategic cities across continents using statecraft themes and semantic similarity.

  • geopolitical_cluster_synthesis: Guides the model to draft an academic monograph based on frozen cluster snapshots.


Installation & Setup

Prerequisites

  • Node.js >= 18.0.0

  • A running Statesman instance (default: http://localhost:3000/api/v1)

1. Build from Source

git clone https://github.com/leouofa/statesman-mcp.git
cd statesman-mcp
npm install
npm run build

2. Environment Configuration

Create a .env file or export environment variables:

STATESMAN_API_URL=http://localhost:3000/api/v1
# STATESMAN_API_KEY=your_optional_token
STATESMAN_TIMEOUT_MS=60000

Client Integration Examples

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "statesman": {
      "command": "node",
      "args": [
        "/absolute/path/to/statesman-mcp/dist/index.js"
      ],
      "env": {
        "STATESMAN_API_URL": "http://localhost:3000/api/v1"
      }
    }
  }
}

Antigravity / Gemini CLI / Cursor

Add to your client configuration:

{
  "mcpServers": {
    "statesman": {
      "command": "npx",
      "args": ["-y", "tsx", "/absolute/path/to/statesman-mcp/src/index.ts"],
      "env": {
        "STATESMAN_API_URL": "http://localhost:3000/api/v1"
      }
    }
  }
}

CLI Options

Usage:
  statesman-mcp [options]

Options:
  -u, --url <url>        Statesman API base URL (default: http://localhost:3000/api/v1)
  -k, --api-key <key>    Optional API key / Bearer token
  -t, --timeout <ms>     Request timeout in milliseconds (default: 60000)
  -h, --help             Display help message

Development & Testing

# Run unit and integration test suite
npm test

# Run tests in watch mode
npm run test:watch

# Compile TypeScript
npm run build

# Start server directly in development
npm run dev

License

MIT © Leonid Medovyy

Available Tools

51 tools
compute_clustersA

Compute live connected-components vector clusters for Countries or Cities across continents without modifying the database.

Inputs: force, level, target_type, full_coverage.

create_cityC

Create a new strategic city record associated with a sovereign country.

Inputs: name (required), country_id (required), themes, description.

create_cluster_reportB

Initiate a 2-Phase Map-Reduce synthesis report on a frozen cluster snapshot.

Inputs: prompt (required), cluster_snapshot_id (required).

create_cluster_snapshotA

Compute connected-components clustering and freeze it immediately into an immutable database snapshot.

Inputs: level (required), title (required), target_type (required), full_coverage.

create_continentC

Create a new continent record in the catalog.

Inputs: name (required), description.

create_countryC

Create a new sovereign country record associated with a continent.

Inputs: name (required), continent_id (required), themes, description.

delete_cityC

Delete a city record.

Inputs: id (required).

delete_cluster_reportA

Delete a synthesis report along with its intermediate summaries and sub-reports.

Inputs: id (required).

delete_cluster_snapshotB

Delete a frozen cluster snapshot along with its cascaded cluster groups and synthesis reports.

Inputs: id (required).

delete_continentB

Delete a continent and its cascaded countries and cities.

Inputs: id (required).

delete_countryB

Delete a country and its cascaded strategic cities.

Inputs: id (required).

find_counterpartsC

Find nearest geopolitical or urban counterparts to a specified country or city using 1024-dimensional pgvector cosine distance.

Inputs: id (required), entity_type (required), limit, country_id, +2 more.

generate_city_embeddingC

Calculate 1024-dimensional vector embedding for a city record.

Inputs: id (required), sync.

generate_country_embeddingC

Calculate 1024-dimensional vector embedding for a country using the configured embedding model.

Inputs: id (required), sync.

generate_deep_synthesisB

Initiate a 3-Phase Hierarchical Deep Synthesis monograph, reusing Phase 1 summaries from a completed parent report.

Inputs: report_id (required), batch_size.

get_cityB

Retrieve details of a strategic city including its structured themes and associated country/continent.

Inputs: id (required), include_embedding.

get_cluster_groupA

Retrieve details of a specific archetype cluster group with all member countries or cities.

Inputs: id (required), include_members.

get_cluster_reportB

Retrieve complete scholarly report content, progress percentage, markdown monograph, and intermediate summaries.

Inputs: id (required), include_summaries, include_sub_reports.

get_cluster_snapshotC

Retrieve details of a frozen cluster snapshot including member groups and generated reports.

Inputs: id (required), include_groups, include_members, include_reports.

get_continentA

Retrieve details of a single continent including its sovereign countries.

Inputs: id (required), include_countries.

get_countryA

Retrieve full profile of a sovereign country including continent, thematic statecraft tags, and strategic cities.

Inputs: id (required), include_cities, include_embedding.

get_job_statusB

Check the status, progress, and result of an ActiveJob/Sidekiq background task.

Inputs: job_id (required).

get_openapi_specB

Retrieve the raw OpenAPI 3.1 specification for the Statesman API.

Inputs: no named parameters.

get_platform_statusA

Get overall platform health, catalog entity counts, embedding coverage stats, and active LLM configuration.

Inputs: no named parameters.

get_report_sub_reportC

Retrieve a single Phase 2 batch analysis.

Inputs: id (required).

get_report_summaryC

Retrieve a single Phase 1 per-cluster scholarly summary.

Inputs: id (required).

get_settingsB

Get embedding completion metrics for Countries and Cities, active embedding/LLM parameters, and context window presets.

Inputs: no named parameters.

list_citiesC

List and filter strategic urban power centers with civic/economic themes and embedding metadata.

Inputs: q, limit, theme, offset, +4 more.

list_cluster_groupsB

List all archetype cluster groups belonging to a specific frozen snapshot.

Inputs: cluster_snapshot_id (required), include_members.

list_cluster_reportsC

List generated multi-phase comparative geopolitics and urban power synthesis reports.

Inputs: limit, offset, status, is_detailed, +2 more.

list_cluster_snapshotsC

List frozen archetype cluster snapshots.

Inputs: limit, offset, target_type, include_groups.

list_continentsA

List world continents registered in Statesman with sovereign country counts.

Inputs: q, limit, offset, include_countries.

list_countriesC

List and filter sovereign countries with statecraft themes, city counts, and vector embedding status.

Inputs: q, limit, theme, offset, +5 more.

list_jobsB

List recent asynchronous background jobs (embedding calculations, LLM discoveries, synthesis reports).

Inputs: limit.

list_report_sub_reportsB

List all Phase 2 intermediate batch analyses belonging to a detailed synthesis report.

Inputs: cluster_report_id (required).

list_report_summariesB

List all Phase 1 per-cluster analyses belonging to a synthesis report.

Inputs: cluster_report_id (required).

populate_cities_bulkB

Trigger bulk LLM city discovery across all countries or a single country.

Inputs: sync, country_id.

populate_continent_countriesC

Discover and populate sovereign countries for a specific continent via LLM generation.

Inputs: id (required), sync.

populate_continentsC

Trigger LLM discovery to populate all 7 standard continents with geopolitical descriptions.

Inputs: sync.

populate_countries_bulkB

Trigger bulk LLM country discovery across all continents or a single continent.

Inputs: sync, continent_id.

populate_country_citiesC

Discover and generate 8-10 strategic cities for a country via LLM extraction.

Inputs: id (required), sync.

trigger_bulk_embeddingsB

Enqueue bulk embedding generation for all Countries or Cities.

Inputs: model_type (required), only_missing.

update_cityC

Update an existing city's attributes, country, or thematic tags.

Inputs: id (required), name, themes, country_id, +1 more.

update_context_windowC

Dynamically update the active LLM context window token size.

Inputs: context_window (required).

update_continentC

Update an existing continent's name or description.

Inputs: id (required), name, description.

update_countryC

Update an existing country's attributes, continent, or thematic tags.

Inputs: id (required), name, themes, description, +1 more.

upsert_cities_batchC

Batch insert or update strategic cities scoped to a specific country.

Inputs: cities (required), country_id (required).

upsert_continents_batchA

Batch insert or update continents matching case-insensitively on name.

Inputs: continents (required).

upsert_countries_batchC

Batch insert or update sovereign countries scoped to a specific continent.

Inputs: countries (required), continent_id (required).

wait_for_jobA

Poll a background job until completion or failure with configurable timeout.

Inputs: job_id (required), timeout_ms, poll_interval_ms.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 51 tools

    Disambiguation3/5

    Most tools map to distinct resources and actions, but several clusters overlap: populate_* versus bulk discovery versus batch upserts, and compute_clusters versus create_cluster_snapshot versus cluster reports. search and find_counterparts are also adjacent enough to require careful selection. Descriptions help, but the tool surface has multiple blurry boundaries.

    Naming Consistency4/5

    The set is overwhelmingly consistent snake_case with verb_noun or verb_noun_qualifier patterns such as list_countries, create_city, and delete_cluster_snapshot. Minor deviations exist in the bare 'search' tool and compound names like generate_deep_synthesis, but the convention is still highly readable.

    Tool Count1/5

    At 51 tools, the server is heavily over-scoped relative to a comparative geopolitics catalog. Many operations could be consolidated into generic entity CRUD, batch, embedding, synthesis, and job-management tools rather than exposing separate tools for every phase and sub-report type.

    Completeness5/5

    The surface covers the full lifecycle for continents, countries, cities, cluster snapshots, cluster groups, reports, summaries, jobs, settings, and embeddings. It includes create/read/update/delete, batch upserts, vector generation, synthesis workflows, polling, and platform introspection, so no obvious operational gap remains.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A self-organizing, persistent semantic memory layer that enables AI agents to store, categorize, and retrieve information using hybrid vector and keyword search. It features autonomous chunking, deduplication, and hierarchical taxonomy management through a PostgreSQL-backed MCP server.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to capture, classify, synthesize, and retrieve persistent knowledge from sources like Obsidian, code, web clippings, transcripts, bookmarks, terminal sessions, and fixes, using FTS5 and semantic search through MCP and REST interfaces.
      10 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI agents to store, semantically recall, update, forget, consolidate, and verify persistent memories with session isolation and hyperbolic concept navigation. It also supports knowledge-graph linking and claim verification for anti-hallucination workflows.
      16
      68 npm
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables agents to navigate, query, and cite a multi-tenant second brain through a four-tier deterministic Merkle index and high-level episode macro-graph, with path-based RBAC/ACL enforcement and NLI-backed citation fact-checking.
      5
      Apache 2.0