Logo von U.S. Census Bureau Data API MCP

U.S. Census Bureau Data API MCP

Organisation
uscensusbureau

The U.S. Census Bureau Data API MCP connects AI Assistants with official Census Bureau statistics.

Herausgeberuscensusbureau
Repositoryus-census-bureau-data-api-mcp
SpracheTypeScript
Forks
30
Sterne
95
Verfügbare Tools
0
Transporttypstdio
Kategorien
LizenzCC0-1.0
Links
  • Tools mit KI-Workflows verbinden

    U.S. Census Bureau Data API MCP stellt MCP-Funktionen bereit, die kompatible KI-Clients und Agenten nutzen können.

  • 0 verfügbare Tools

    Sehen Sie sich unten die aufrufbaren Aktionen an, einschließlich Namen und Beschreibungen, sofern der Server diese bereitstellt.

  • Konfiguration zum Kopieren

    Nutzen Sie die Installationsbeispiele, um diesen Server in Ihrem bevorzugten MCP-Client zu konfigurieren.

  • Open-Source-Kennzahlen

    95 Sterne und 30 Forks im verlinkten Repository.

U.S. Census Bureau Data API MCP

License: CC0-1.0 MCP Project Build MCP Project - Lint MCP Server - Tests MCP Database - Tests MCP Server - Test Coverage MCP Database - Test Coverage

Bringing official Census Bureau statistics to AI assistants everywhere.

The U.S. Census Bureau Data API MCP is a Model Context Protocol (MCP) server that connects AI assistants with data from the Census Data API and other official Census Bureau sources. This project is built using the MCP Typescript SDK.

Contents

Getting Started

To get started, you will need:

  • A valid Census Bureau Data API key
  • Docker (i.e. Docker Desktop)
  • Node 18+

Using the MCP Server

To use the U.S. Census Bureau Data API MCP server:

  1. Clone or download the project locally.
  2. In a terminal window, navigate to the project’s root directory and run docker compose --profile prod run --rm census-mcp-db-init sh -c "npm run migrate:up && npm run seed" to pull data from the Census Data API into the local database. This is only required on first-time setup.
  3. Configure your AI Assistant to use the MCP Server (see below).
  4. Start your AI Assistant.

Here is an example configuration file that includes the appropriate scripts for launching the MCP Server:

{
  "mcpServers": {
    "mcp-census-api": {
      "command": "bash",
      "args": [
        "/Path/To/Server/us-census-bureau-data-api-mcp/scripts/mcp-connect.sh"
      ],
      "env": {
        "CENSUS_API_KEY": "YOUR_CENSUS_API_KEY"
      }
    }
  }
}

Note that the CENSUS_API_KEY variable is required. This defines the env variable in the MCP Client and passes it to the MCP server via the mcp-connect script.

Be sure to update the path to the us-census-bureau-data-api-mcp directory in args and provide a valid CENSUS_API_KEY.

Updating the MCP Server

When a new version of this project is released, you will need to rebuild the production environment for the latest features. From the mcp-db/ directory, run the following:

npm run prod:down
npm run prod:build

After that, you can relaunch your MCP Client and it should connect to the server again.

How the MCP Server Works

The U.S. Census Bureau Data API MCP server uses data from the Census Data API and other official sources to construct contextually rich data and statistics for use with AI Assistants. The Census Data API is the primary source of data but some of the API's data is pulled down to a local postgres container to enable more robust and performant search functionality. Below is an illustration of how user prompts are processed by AI Assistants and the MCP Server.

Illustration of how the MCP Server works, starting with a user prompt, processing by an AI Assistant, tool or resource calls to the U.S. Census Bureau Data API MCP server, and finally queries to the local postgres database or the Census Data API.

Development

Run docker compose --profile dev up from the root of the project to build the containers. This starts the MCP Database containers that runs migrations and seeds a local postgres database to supplement information from the Census Bureau API. It also starts the MCP Server itself.

By default, all logging functions are disabled in the mcp-server to prevent json validation errors when interacting with the MCP server through MCP clients. To enable logging for development purposes, set DEBUG_LOGS=true when interacting with the server directly using the examples below, e.g. echo '{CALL_ARGUMENTS}' docker exec -e DEBUG_LOGS=true -i -e CENSUS_API_KEY=YOUR_CENSUS_API_KEY mcp-server node dist/index.js.

Testing

This project uses Vitest to test the MCP Server and MCP Database.

MCP Server Testing

Prior to running the MCP Server tests, a valid Census Bureau API key is required. This key should be defined in the .env file of the mcp-server directory. The sample.env offers an example of how this .env file should look.

To run tests, navigate to the mcp-server/ directory and run npm run test. To run ESLint, run npm run lint from the same directory.

MCP Database Testing

A .env file needs to be created in the mcp-db/ directory with a valid DATABASE_URL variable defined. The sample.env in the same directory includes the default value.

To run tests, navigate to the mcp-db/ directory and run npm run test.

MCP Server Architecture

  • mcp-server/src/ - Source code for the MCP Server.
  • mcp-server/src/index.ts - Starts the MCP Server and registers tools.
  • mcp-server/src/server.ts - Defines the McpServer class that handles calls to the server, e.g. how tools/list and tools/calls respond to requests
  • mcp-server/src/tools/ - Includes tool definitions and shared classes, e.g. BaseTool and ToolRegistry, to reduce repetition and exposes the tools list to the server
  • mcp-server/src/schema/ - Houses each tool’s schema and is used to validate schemas in tests

Available Methods

The MCP server exposes several methods: tools/list, tools/call, prompts/list, and prompts/get.

Available Tools

This section covers tools that can be called.

List Datasets

The list-datasets tool is used for fetching a subset of metadata for all datasets that are available in the Census Bureau's API.
It requires no arguments.

Fetch Dataset Geography

The fetch-dataset-geography tool is used for fetching available geography levels for filtering a given dataset. It accepts the following arguments:

  • Dataset (Required) - The identifier of the dataset, e.g. 'acs/acs1'
  • Year (Optional) - The vintage of the dataset, e.g. 1987

Fetch Aggregate Data

The fetch-aggregate-data tool is used for fetching aggregate data from the Census Bureau's API. It accepts the following arguments:

  • Dataset (Required) - The identifier of the dataset, e.g. 'acs/acs1'
  • Year (Required) - The vintage of the dataset, e.g. 1987
  • Get (Required) - An object that is required that accepts 2 optional arguments:
    • Variables (optional) - An array of variables for filtering responses by attributes and rows, e.g. 'NAME', 'B01001_001E'
    • Group (Optional) - A string that returns a larger collection of variables, e.g. S0101
  • For (Optional) - A string that restricts geography to various levels and is required in most datasets
  • In (Optional) - A string that restricts geography to smaller areas than state level
  • UCGID (Optional) - A string that restricts geography by Uniform Census Geography Identifier (UCGID), e.g. 0400000US41
  • Predicates (Optional) - Filter options for the dataset, e.g. 'for': 'state*'
  • Descriptive (Optional) - Adds variable labels to API response (default: false), e.g. true

Resolve Geography FIPS Tool

The resolve-geography-fips tool is used to search across all Census Bureau geographies to return a list of potential matches and the correct FIPS codes and parameters used to query data in them. This tool accepts the following arguments:

  • Geography Name (Required) - The name of the geography to search, e.g. Philadelphia
  • Summary Level (Optional) - The summary level to search. Accepts name or summary level code, e.g. Place, 160

Available Prompts

This section covers prompts that can be called. According to the Model Context Protocol docs, prompts are "pre-built instruction templates that tell the model to work with specific tools and resources". This means that prompts override the default model behavior. Prompts are not a menu of allowed questions. They are instructions, not constraints on server capability.

Population

This get_population_data prompt retrieves population statistics for US states, counties, cities, and other geographic areas. It resolves geographic names to their corresponding FIPS codes before fetching data. This prompt accepts the following argument:

  • geography_name (required): Name of the geographic area (state, county, city, etc.)

Helper Scripts

For easier command-line usage, this project includes bash helper scripts in the scripts/dev directory that wrap the complex Docker commands and handle the CENSUS_API_KEY parameter automatically.

Additional Information

For more information about the parameters above and all available predicates, review the Census Bureau's API documentation.

Installation

TypingMind
Voraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "uscensusbureau-us-census-bureau-data-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "us-census-bureau-data-api-mcp"
      ]
    }
  }
}

U.S. Census Bureau Data API MCP MCP mit mehreren KI-Modellen nutzen

TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. Sobald U.S. Census Bureau Data API MCP verbunden ist, können Sie die Integration mit verschiedenen KI-Modellen in TypingMind verwenden, statt sie für jedes Modell separat einzurichten. Diese MCP-Integration läuft lokal über den TypingMind-MCP-Konnektor auf Ihrem Gerät.

Einrichtungsanleitung für den lokalen Konnektor

Nutzen Sie diese Option, wenn der MCP-Server Zugriff auf lokale Dateien, Apps oder private Ressourcen auf Ihrem Computer benötigt.

1

MCP-Einstellungen öffnen

Gehen Sie in TypingMind zu „Einstellungen“, „Erweiterte Einstellungen“ und dann „Model Context Protocol“ und wählen Sie „Konnektor-Setup“.

  1. Öffnen Sie TypingMind in Ihrem Browser.
  2. Klicken Sie auf das Symbol „Optionen“.
  3. Gehen Sie zu „Erweiterte Einstellungen“.
  4. Öffnen Sie den Abschnitt „Model Context Protocol“.
  5. Klicken Sie auf „Konnektor-Setup“ und wählen Sie „Dieses Gerät“.
Einrichtungsbildschirm des TypingMind-MCP-Konnektors mit ausgewählter Option „Dieses Gerät“
2

Konnektor-Befehl ausführen

Wählen Sie „Dieses Gerät“, kopieren Sie den Befehl aus TypingMind und führen Sie ihn im Terminal aus. Lassen Sie den Prozess laufen, solange Sie MCP verwenden.

  1. Kopieren Sie den in TypingMind angezeigten Einrichtungsbefehl.
  2. Öffnen Sie unter macOS Terminal bzw. unter Windows Windows Terminal.
  3. Fügen Sie den Befehl ein und führen Sie ihn aus.
  4. Bestätigen Sie die Paketinstallation, wenn Sie im Terminal zum Fortfahren aufgefordert werden.
  5. Lassen Sie das Terminalfenster geöffnet und den Prozess darin laufen, solange Sie MCP-Tools verwenden.
3

U.S. Census Bureau Data API MCP als Server hinzufügen

Wenn der Konnektorstatus „Bereit“ anzeigt, klicken Sie auf „Server ändern“ und fügen Sie die MCP-Server-Konfiguration ein.

  1. Warten Sie, bis der Konnektorstatus „Bereit“ anzeigt.
  2. Klicken Sie auf „Server ändern“.
  3. Fügen Sie die MCP-Server-Konfiguration für U.S. Census Bureau Data API MCP ein.
  4. Speichern Sie die Serverliste.
  5. Aktualisieren Sie die Ansicht, um bei Bedarf zu prüfen, ob der Konnektor weiterhin bereit ist.
MCP-Einstellungen in TypingMind mit aktivem Server und der Schaltfläche „Server ändern“
{
  "mcpServers": {
    "uscensusbureau-us-census-bureau-data-api-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "us-census-bureau-data-api-mcp"
      ]
    }
  }
}
4

Verbindung modellübergreifend nutzen

Speichern Sie die Serverliste, öffnen Sie „Plugins“ und aktivieren Sie die MCP-Tools von U.S. Census Bureau Data API MCP. Wählen Sie dann ein beliebiges unterstütztes KI-Modell in TypingMind und verwenden Sie die Tools im Chat oder weisen Sie sie einem KI-Agenten zu.

  1. Öffnen Sie die Seite „Plugins“ in TypingMind.
  2. Aktivieren Sie die MCP-Tools von U.S. Census Bureau Data API MCP.
  3. Starten Sie einen Chat und wählen Sie das KI-Modell, das Sie verwenden möchten.
  4. Nutzen Sie die MCP-Tools im Chat oder weisen Sie sie einem KI-Agenten zu.
  5. Wechseln Sie bei Bedarf zu einem anderen KI-Modell, ohne die MCP-Verbindung erneut herzustellen.
TypingMind-Chat mit aktivierten MCP-Tools und einem ausgewählten KI-Modell
Können Sie mir mit U.S. Census Bureau Data API MCP bei dieser Aufgabe helfen?
U.S. Census Bureau Data API MCP
Gerne. Ich habe es gelesen.
Das habe ich mit U.S. Census Bureau Data API MCP gefunden.

Häufig gestellte Fragen

Wofür wird der MCP-Server U.S. Census Bureau Data API MCP verwendet?

U.S. Census Bureau Data API MCP ist ein MCP-Server, über den kompatible KI-Clients auf externe Tools und Kontext zugreifen können. In TypingMind können Sie diesen MCP-Server einmal hinzufügen und seine Tools in Ihrem KI-Arbeitsbereich verfügbar machen.

Kann ich U.S. Census Bureau Data API MCP MCP mit mehreren KI-Modellen in TypingMind verwenden?

Ja. TypingMind bindet MCP-Tools auf Arbeitsbereichsebene ein. So können Sie U.S. Census Bureau Data API MCP mit verschiedenen KI-Modellen wie Claude, ChatGPT, Gemini oder anderen in TypingMind konfigurierten Modellen verwenden, ohne den MCP-Server für jedes Modell separat einzurichten.

Warum U.S. Census Bureau Data API MCP MCP mit TypingMind nutzen?

TypingMind ist eine der besten Oberflächen für LLM-Chats, da es mehrere KI-Modelle, Prompts, Plugins, KI-Agenten, API-Schlüssel und MCP-Tools in einem Arbeitsbereich vereint. Sobald U.S. Census Bureau Data API MCP verbunden ist, können Sie die zugehörigen MCP-Tools mit Ihren bevorzugten Modellen nutzen und Ihre Chat-Abläufe in TypingMind übersichtlich organisieren.

Wie verbinde ich U.S. Census Bureau Data API MCP MCP mit TypingMind?

U.S. Census Bureau Data API MCP wird über den lokalen MCP-Konnektor von TypingMind angebunden. Das ist die beste Wahl, wenn der MCP-Server auf lokale Dateien, Desktop-Apps, Befehlszeilentools oder private Ressourcen auf Ihrem Computer zugreifen muss.

Welche Tools stellt U.S. Census Bureau Data API MCP MCP in TypingMind bereit?

U.S. Census Bureau Data API MCP stellt MCP-Funktionen bereit, die Sie auf der Plugins-Seite in TypingMind aktivieren und im Chat verwenden oder KI-Agenten zuweisen können.

Muss ich meine API-Schlüssel mit TypingMind teilen, um U.S. Census Bureau Data API MCP MCP zu verwenden?

Nein. TypingMind arbeitet vorrangig lokal, sodass Sie die Kontrolle über Ihre Modellanbieter, API-Schlüssel, Prompts und MCP-Konfiguration behalten. Falls U.S. Census Bureau Data API MCP eine Authentifizierung erfordert, fügen Sie beim Erstellen der Verbindung die erforderlichen Header, OAuth-Einstellungen oder die lokale Konfiguration für diesen MCP-Server hinzu.

Ähnliche MCP-Server

Alle

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇