Use MCP
This page describes how to run a local agent and connect to a Data Commons MCP server to query datacommons.org, using the centrally hosted server at https://api.datacommons.org/mcp.
For advanced use cases, such as developing a custom agent, Run a self-hosted MCP server describes how to run your own local server and connect to it from an agent.
For procedures for Custom Data Commons instances, please see instead Use MCP tools.
We provide specific instructions for the following clients:
-
Google Antigravity (CLI or IDE)
-
A sample basic agent based on the Google Agent Development Kit
For other clients/agents, see the relevant documentation; you should be able to easily adapt the configurations detailed here.
Prerequisites
This is required for all agents, regardless of the server deployment:
- A (free) Data Commons API key. To obtain an API key, go to https://apikeys.datacommons.org and request a key for the
api.datacommons.orgdomain.
Use Google Antigravity
- Download and install Google Antigravity from https://antigravity.google/download.
- To configure Antigravity to connect to the Data Commons server, use the IDE or a text editor to open
~/.gemini/config/mcp_config.jsonand add the following:{ "mcpServers": { "datacommons-mcp": { "serverUrl": "https://api.datacommons.org/mcp", "headers": { "X-API-Key": "YOUR_DATA_COMMONS_API_KEY" } } } } - Run the IDE or CLI as usual.
- Start sending natural-language queries.
To see the Data Commons tools, use /mcp tools. To see the Data Commons resources, use /mcp resources.
Tip: Data Commons provides a set of agent skills as server resources, so you don’t need to provide any Data Commons-specific customizations.
Use the sample agent
Additional prerequisites
In addition to the Data Commons API key, you will need:
Tip: You do not need to install the Google ADK; when you use the command we provide to start the agent, it downloads the ADK dependencies at run time.
Install
From the desired directory, clone the agent-toolkit repo:
git clone https://github.com/datacommonsorg/agent-toolkit.git
Run
- Go to the root directory of the repo:
cd agent-toolkit - Run the agent using one of the following methods.
Web UI (recommended)
- Run the following command:
uvx --from google-adk adk web ./packages/datacommons-mcp/examples/sample_agents/ - Point your browser to the address and port displayed on the screen (e.g.
http://127.0.0.1:8000/). The Agent Development Kit Dev UI is displayed. - From the Type a message box, type your query for Data Commons or select another action.
Command line interface
- Run the following command:
uvx --from google-adk adk run ./packages/datacommons-mcp/examples/sample_agents/basic_agent - Enter your queries at the
Userprompt in the terminal.
Customize the agent
To customize the sample agent, you can make changes directly to the Python files. You’ll need to restart the agent any time you make changes.
Customize the model
To change to a different LLM or model version, edit the AGENT_MODEL constant in packages/datacommons-mcp/examples/sample_agents/basic_agent/agent.py.
Customize agent behavior
The agent’s behavior is determined by prompts provided in the AGENT_INSTRUCTIONS in packages/datacommons-mcp/examples/sample_agents/basic_agent/instructions.py.
You can add your own prompts to modify how the client processes the results of tool calls. See the Google ADK page on LLM agent instructions for tips on how to write good prompts.
Tip: Data Commons provides a set of agent skills as server resources, so you don’t need to provide any Data Commons-specific instructions.
Sample queries
The Data Commons MCP tools excel at natural-language queries that involve:
- Comparisons between two or more entities, such as countries or metrics
- Exploring data available for a given topic
Here are some examples of such queries:
- “What health data do you have for Africa?”
- “What data do you have on water quality in Zimbabwe?”
- “Compare the life expectancy, economic inequality, and GDP growth for BRICS nations.”
- “Generate a concise report on income vs diabetes in US counties.”
Page last updated: September 02, 2026 • Send feedback about this page