Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
d6241c9
remove references to dataclass objects
kmoscoe Jun 12, 2025
101c5fd
Fix a copy-paste error.
kmoscoe Jun 12, 2025
504d852
remove extra file
kmoscoe Jun 12, 2025
1697b22
Merge branch 'datacommonsorg:master' into master
kmoscoe Jun 12, 2025
426a81c
Merge branch 'master' of https://github.com/datacommonsorg/docsite
kmoscoe Jun 24, 2025
a40c7c8
Merge branch 'master' of https://github.com/kmoscoe/docsite
kmoscoe Jun 24, 2025
4c69c15
Merge branch 'datacommonsorg:master' into master
kmoscoe Sep 17, 2025
156cff0
Create placeholders for LLM pages
kmoscoe Sep 23, 2025
a975d24
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Sep 23, 2025
e3883e3
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Sep 23, 2025
a4e40a4
rename to MCP
kmoscoe Sep 23, 2025
1fbd187
complete rename
kmoscoe Sep 23, 2025
82228b1
remove old file
kmoscoe Sep 23, 2025
e656552
Changes from Keyur
kmoscoe Sep 23, 2025
9101325
Add target tag
kmoscoe Sep 23, 2025
d003cc1
Rewording suggested by Keyur
kmoscoe Sep 23, 2025
6b94948
Remove extraneous text
kmoscoe Sep 23, 2025
2ecd2bf
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Oct 15, 2025
4b26adc
Fix a copy-paste error.
kmoscoe Jun 12, 2025
7d15bbe
Migrate MCP docs to docsite
kmoscoe Oct 15, 2025
f481c40
Restructuring
kmoscoe Oct 15, 2025
5d70c4a
Remove unused file
kmoscoe Oct 15, 2025
b241392
Add TOCs etc.
kmoscoe Oct 15, 2025
f78ccd3
Update var formatting
kmoscoe Oct 15, 2025
923f7c5
comments from Keyur
kmoscoe Oct 16, 2025
7ec3018
another change from Keyur
kmoscoe Oct 16, 2025
3fe9f4f
Update mcp/index.md
kmoscoe Oct 16, 2025
93db32f
Changes from Christie
kmoscoe Oct 16, 2025
5cd3a31
Apply suggestion from @clincoln8
kmoscoe Oct 16, 2025
655aece
More changes from Christie
kmoscoe Oct 16, 2025
1944f14
Changes from Dan
kmoscoe Oct 20, 2025
21d43ee
Link fixes
kmoscoe Oct 20, 2025
ab810ea
Remove MCP inspector info
kmoscoe Oct 21, 2025
7f8521f
Add more context to agent dev doc
kmoscoe Oct 21, 2025
4f880c1
fix formatting
kmoscoe Oct 21, 2025
cff1ac7
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Oct 24, 2025
3bef318
Create placeholders for LLM pages
kmoscoe Sep 23, 2025
74a7ab2
merge
kmoscoe Oct 24, 2025
1b768e9
Slight rewording based on comment from Christie
kmoscoe Oct 24, 2025
4047f23
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Oct 27, 2025
c22bdba
Lots of restructuring
kmoscoe Oct 29, 2025
5faf6ef
More work on Gemini CLI extension
kmoscoe Nov 3, 2025
432bbb9
More changes
kmoscoe Nov 3, 2025
1154f25
more changes
kmoscoe Nov 3, 2025
ece8882
more changes
kmoscoe Nov 3, 2025
d695244
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Nov 3, 2025
764ea9f
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Nov 3, 2025
f81946b
Update mcp/run_tools.md
kmoscoe Nov 3, 2025
1fb1640
implement suggestions from Christie
kmoscoe Nov 3, 2025
c5fd5fe
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Nov 3, 2025
90ddfc3
Add some bullets to comparison section
kmoscoe Nov 3, 2025
a9ad87f
Fix update section
kmoscoe Nov 3, 2025
4930a5b
rename "prompt" to "context"
kmoscoe Nov 4, 2025
bb278f8
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Nov 11, 2025
9fa9f0f
add mention of Gemini CLI extension for custom DC
kmoscoe Nov 12, 2025
c3edbe0
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Nov 12, 2025
977ea45
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Nov 12, 2025
6c2bd5c
Update custom DC vars procedure
kmoscoe Nov 17, 2025
4d67fc6
Remove reference to .env file in extension run
kmoscoe Nov 21, 2025
9a34f12
Merge branch 'master' into mcp
kmoscoe Nov 21, 2025
2bb5ca3
slight fix
kmoscoe Nov 24, 2025
e3a7193
Add section on creating a custom extension
kmoscoe Nov 24, 2025
25cad3a
Some rewording
kmoscoe Nov 25, 2025
7c71b3a
Fix formatting
kmoscoe Nov 25, 2025
8dd7f75
More revisions and edits
kmoscoe Nov 25, 2025
9ea74cd
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Nov 25, 2025
9f58ec3
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Nov 25, 2025
ab6fb59
Remove file from other branch
kmoscoe Nov 25, 2025
9bc3f7f
minor edits
kmoscoe Nov 25, 2025
2fac33b
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Nov 25, 2025
ff33361
Merge branch 'master' into mcp
kmoscoe Dec 2, 2025
45e8a57
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Dec 3, 2025
f99cd81
Add Windows command
kmoscoe Dec 3, 2025
482c650
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Dec 3, 2025
fdeea2e
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Dec 3, 2025
5a6fb16
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Dec 9, 2025
0323953
Add warning about nvm
kmoscoe Dec 9, 2025
5f9dcca
Remove warning
kmoscoe Dec 9, 2025
b5ddb9c
Remove reference to node.js
kmoscoe Dec 9, 2025
c09b44c
Update mcp/run_tools.md
kmoscoe Dec 9, 2025
9f9a9bd
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Dec 16, 2025
6bb745c
Add required header to connect to a remote server
kmoscoe Dec 17, 2025
7ededf3
Add additional accept type
kmoscoe Dec 17, 2025
1550ed8
Add code for sample agent headers
kmoscoe Dec 17, 2025
75f5150
Apply suggestion from @gemini-code-assist[bot]
kmoscoe Dec 17, 2025
6395a67
Remove headers from basic agent
kmoscoe Dec 17, 2025
fe34778
Merge branch 'datacommonsorg:master' into mcp
kmoscoe Dec 17, 2025
0ca77f9
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Dec 17, 2025
1c114f1
Revert last change
kmoscoe Dec 17, 2025
4db9a2c
Start of deploying MCP server to GCP
kmoscoe Dec 30, 2025
98b3265
Complete rewrite of hosting MCP server content
kmoscoe Jan 7, 2026
2073fdb
more changes
kmoscoe Jan 8, 2026
c5f95b0
More changes
kmoscoe Jan 12, 2026
32bacd9
formatting fixes
kmoscoe Jan 12, 2026
44395c9
add reference to custom DC doc
kmoscoe Jan 12, 2026
c131f42
HTML fix
kmoscoe Jan 12, 2026
5640448
Update custom_dc/mcp_server_cloud.md
kmoscoe Jan 12, 2026
cfd71ad
Update custom_dc/mcp_server_cloud.md
kmoscoe Jan 12, 2026
6eabd20
Remove a redundant step
kmoscoe Jan 12, 2026
5a8511e
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Jan 12, 2026
97a8139
Merge changes from Code Assist
kmoscoe Jan 12, 2026
1f3d4c3
Remove specifics of scaling etc. and refer to Cloud Run docs instead
kmoscoe Jan 12, 2026
0d8a04b
rename file
kmoscoe Jan 13, 2026
887f81e
Fix broken link
kmoscoe Jan 13, 2026
b185be5
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Jan 13, 2026
fd1356b
First round of changes for hosted MCP server
kmoscoe Jan 13, 2026
4593a3f
more changes
kmoscoe Jan 13, 2026
63fc208
First set of changes to run_tools file
kmoscoe Jan 13, 2026
b982f47
start of changes to custom DC docs
kmoscoe Jan 13, 2026
9fc7d41
More restructuring and file name change
kmoscoe Jan 14, 2026
59b01f4
More restructuring and expansion of custom DC doc
kmoscoe Jan 14, 2026
ca48c96
Restructure: move sample agent to separat page, and move local proced…
kmoscoe Jan 14, 2026
73f2d57
Merge branch 'master' of https://github.com/datacommonsorg/docsite in…
kmoscoe Jan 14, 2026
dc6e212
Remove develop agent page and consolidate all self-hosted instruction…
kmoscoe Jan 14, 2026
f4988b2
More changes for hosted MCP
kmoscoe Jan 14, 2026
2c8351d
complete first draft of hosted MCP changes
kmoscoe Jan 20, 2026
1f02ad7
Update mcp/run_tools.md
kmoscoe Jan 20, 2026
3c634d8
Update mcp/run_tools.md
kmoscoe Jan 20, 2026
db863a1
Update mcp/run_tools.md
kmoscoe Jan 20, 2026
17f8a86
Update custom_dc/run_mcp_tools.md
kmoscoe Jan 20, 2026
0108a4b
fix grammatical errors
kmoscoe Jan 20, 2026
71496d4
minor changes
kmoscoe Jan 20, 2026
4d47452
minor changes
kmoscoe Jan 20, 2026
a91fbd9
minor fix
kmoscoe Jan 20, 2026
07e0282
Add way of setting the API key literally in settings.json
kmoscoe Jan 20, 2026
d1ead01
added tip about Gemini CLI env var
kmoscoe Jan 20, 2026
3b43807
Add another way of using the key in standalone mode
kmoscoe Jan 20, 2026
ba7f0b9
Rename custom DC file
kmoscoe Jan 27, 2026
2030013
Add MCP to API key reqs
kmoscoe Jan 28, 2026
40c0a9c
Merge branch 'master' into mcp
kmoscoe Feb 2, 2026
ae9df7e
Fix broken link
kmoscoe Feb 2, 2026
bef4af1
update stable release date
kmoscoe Feb 2, 2026
582a430
Merge branch 'mcp' of https://github.com/kmoscoe/docsite into mcp
kmoscoe Feb 2, 2026
5ec052e
markdown fix
kmoscoe Feb 3, 2026
c4bd5b9
Incorporate feedback from Carolyn
kmoscoe Feb 3, 2026
bc31b9c
Update graphic
kmoscoe Feb 3, 2026
750711a
Fix broken link
kmoscoe Feb 3, 2026
63d12c7
Removed references to custom DC
kmoscoe Feb 3, 2026
d9cab13
Update custom_dc/run_mcp_tools.md
kmoscoe Feb 4, 2026
15bd390
Update custom_dc/run_mcp_tools.md
kmoscoe Feb 4, 2026
8df11f4
Incorporate suggestions from Christie
kmoscoe Feb 4, 2026
4d13ae0
Update custom_dc/run_mcp_tools.md
kmoscoe Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Finally, an R client library is available from a third-party provider, [Tidy Int
A key is required for APIs to authenticate and authorize requests, as follows:
- All REST [V2](rest/v2/index.md) APIs. These requests are served by endpoints at `api.datacommons.org`.
- [Python and Pandas V2](python/v2/index.md) APIs, also served by `api.datacommons.org`.
- Data Commons MCP server requests. These are served by `api.datacommons.org/mcp`.
- All requests coming from a custom Data Commons instance. These are also served by `api.datacommons.org`.
- Data Commons NL API requests (used by the [DataGemma](https://ai.google.devgit/gemma/docs/datagemma){: target="_blank"} tool). These are served by endpoints at `nl.datacommons.org`.

Expand Down
Binary file removed assets/images/mcp.png
Binary file not shown.
Binary file added assets/images/mcp1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/mcp2.png
Comment thread
kmoscoe marked this conversation as resolved.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 45 additions & 12 deletions custom_dc/deploy_mcp_cloud.md → custom_dc/run_mcp_tools.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
---
layout: default
title: Run an MCP server in Google Cloud
title: Run an MCP server
nav_order: 9
parent: Build your own Data Commons
---

{:.no_toc}
# Run an MCP server in Google Cloud
# Run an MCP server

To use Data Commons MCP tools with a Custom Data Commons, you must run your own instance of the Data Commons MCP server. This page describes how to run a server locally and in Google Cloud.

> **Important**:
> If you have not rebuilt your Data Commons image since the stable release of 2026-01-29, you must [sync to the latest stable release](/custom_dc/build_image.html#sync-code-to-the-stable-branch), [rebuild your image](/custom_dc/build_image.html#build-package) and [redeploy](/custom_dc/deploy_cloud.html#manage-your-service).

* TOC
{:toc}

## Run a local MCP server

You can use any AI agent to spawn a local MCP server as a subprocess, or start a standalone server and connect to it from any client. For the most part, the procedures to do so are the same as those provided in [Run your own MCP server](/mcp/run_tools.html#self-hosted). The main difference is that you must set additional environment variables, as described below.

### Prerequisites

- Install `uv` for managing and installing Python packages; see the instructions at <https://docs.astral.sh/uv/getting-started/installation/>{: target="_blank"}.

### Configure environment variables

To run against a Custom Data Commons instance, you must set the following required variables:
- <code>DC_API_KEY="<var>YOUR API KEY</var>"</code>
- `DC_TYPE="custom"`
Comment thread
kmoscoe marked this conversation as resolved.
- <code>CUSTOM_DC_URL="<var>YOUR_INSTANCE_URL</var>"</code>

Various other optional variables are also available; all are documented in [packages/datacommons-mcp/.env.sample](https://github.com/datacommonsorg/agent-toolkit/blob/main/packages/datacommons-mcp/.env.sample){: target="_blank"}.

You can set variables in the following ways:
1. In a shell/startup script (e.g. `.bashrc`).
1. Use an `.env` file. This is useful if you're setting multiple variables, to keep all settings in one place. Copy the contents of [`.env.sample`](https://github.com/datacommonsorg/agent-toolkit/blob/main/packages/datacommons-mcp/.env.sample){: target="_blank"} into a file called `.env` in the directory where you plan to run the server and/or agent.
1. If you are using Gemini CLI (not the extension), you can use the `env` option in the `settings.json` file.

<script src="/assets/js/customdc-doc-tabs.js"></script>

## Run the MCP Server in Google Cloud Platform

If you have built a custom agent or Gemini CLI extension which you want to make publicly available, this page describes how to run the [Data Commons MCP server](https://pypi.org/project/datacommons-mcp/) in the cloud, using Google Cloud Run.

Since setting up an MCP server is a simple, one-time setup, there's no need to use Terraform to manage it. Data Commons provides a prebuilt Docker image in the Artifact Registry, so you only need to set up a new Cloud Run service to point to it.

## Prebuilt images
### Prebuilt images

There are several versions of the image available, viewable at <https://console.cloud.google.com/artifacts/docker/datcom-ci/us/gcr.io/datacommons-mcp-server>. We recommend that you choose a production version with a specific version number, to ensure that changes introduced by the Data Commons team don't break your application.

## Before you start: decide on a hosting model
### Before you start: decide on a hosting model

There are several ways you can host the MCP server in Cloud Run, namely:

Expand All @@ -25,13 +59,13 @@ There are several ways you can host the MCP server in Cloud Run, namely:

In this page, we provide steps for running the Data Commons MCP server as a standalone container. If you want to go with the sidecar option, please see [Deploying multiple containers to a service (sidecars)](https://docs.cloud.google.com/run/docs/deploying#sidecars){: target="_blank"} for additional requirements and setup procedures.

## Prerequisites
### Prerequisites

The following procedures assume that you have set up the following Google Cloud Platform services, using the [Terraform scripts](deploy_cloud.md#terraform):
- A service account and roles.
- A Google Cloud Secret Manager secret for storing your Data Commons API key.

## Create a Cloud Run Service for the MCP server
### Create a Cloud Run Service for the MCP server

The following procedure sets up a bare-bones container service. To set additional options, such as request timeouts, instance replication, etc., please see [Configure Cloud Run services](https://docs.cloud.google.com/run/docs/configuring){: target="_blank"} for details.

Expand Down Expand Up @@ -89,17 +123,16 @@ The following procedure sets up a bare-bones container service. To set additiona

<script src="/assets/js/customdc-doc-tabs.js"></script>

## Connect to the server from a remote client
### Connect to the server from a remote client

For details, see the following pages:
- [Connect to the server from a local Gemini CLI client](/mcp/run_tools.html#gemini-cli-remote)
- [Connect to the server from a local agent](/mcp/run_tools.html#remote)
For details, see [Configure an agent to connect to the running server](/mcp/run_tools.html#standalone-client).

The HTTP URL parameter is the Cloud Run App URL, if you are exposing the service directly, or a custom domain URL if you are using a load balancer and domain mapping.

## Troubleshoot deployment issues
### Troubleshoot deployment issues

### Container fails to start
{:.no_toc}
#### Container fails to start

If you see this error message:

Expand Down
111 changes: 0 additions & 111 deletions mcp/develop_agent.md

This file was deleted.

26 changes: 17 additions & 9 deletions mcp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,38 @@ has_children: true

The Data Commons [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) service gives AI agents access to the Data Commons knowledge graph and returns data related to statistical variables, topics, and observations. It allows end users to formulate complex natural-language queries interactively, get data in textual, structured or unstructured formats, and download the data as desired. For example, depending on the agent, a user can answer high-level questions such as "give me the economic indicators of the BRICS countries", view simple tables, and download a CSV file of the data in tabular format.

The MCP server returns data from datacommons.org by default or can be configured to query a Custom Data Commons instance.
The MCP server returns data from datacommons.org ("base") by default. It can also be configured to query a Custom Data Commons instance.

The server is a Python binary based on the [FastMCP 2.0 framework](https://gofastmcp.com). A prebuilt package is available at <https://pypi.org/project/datacommons-mcp/>.
For base Data Commons, the server is available as a hosted managed deployment to which you can connect from any AI agent running locally or remotely.
Comment thread
kmoscoe marked this conversation as resolved.

At this time, there is no centrally deployed server; you run your own server, and any client you want to connect to it.
![base Data Commons](/assets/images/mcp1.png)

![alt text](/assets/images/mcp.png)
You can also run your own MCP server locally, or in Google Cloud Platform. If you want to use the server to query a Custom Data Commons instance, you _must_ run your own. The server is available as:
- A prebuilt Python package for running locally
- A prebuilt Docker image for running in a Google Cloud Run service

You can run the server and client locally, or you can run the server and client on different machines.
![base or Custom Data Commons](/assets/images/mcp2.png)

## Tools

The server currently supports the following tools:

- `search_indicators`: Searches for available variables and/or topics (a hierarchy of sub-topics and member variables) for a given place or metric.
- `get_observations`: Fetches statistical data for a given variable and place.
- `search_indicators`: Searches for available variables and/or topics (a hierarchy of sub-topics and member variables) for a given place or metric. This allows queries like:
- "Tell me what data you have about health in Egypt."
- "Do you have GDP data for Eastern European countries?"
- "What census data do you have for the U.S.?"
- `get_observations`: Fetches statistical data for a given variable and place. This allows queries like:
- "List the population of Canada since 1964."
- "Rank-order the GDP for all countries in Eastern Europe."
- "Compare the life expectancy between different countries in South America."

## Clients

To connect to the Data Commons MCP Server, you can use any available AI application that supports MCP, or your own custom agent.

The server supports both standard MCP [transport protocols](https://modelcontextprotocol.io/docs/learn/architecture#transport-layer):
- Stdio: For clients that connect directly using local processes
For self-hosted deployments, the server supports both standard MCP [transport protocols](https://modelcontextprotocol.io/docs/learn/architecture#transport-layer):
- Streamable HTTP: For clients that connect remotely or otherwise require HTTP (e.g. Typescript)
- Stdio: For clients that connect directly using local processes

See [Run MCP tools](run_tools.md) for procedures for using [Gemini CLI](https://github.com/google-gemini/gemini-cli) and the [Gemini CLI Data Commons extension](https://geminicli.com/extensions/).

Expand Down
Loading
Loading