Connecting Custom Tools: Exposing Private APIs via Custom MCP Servers
Learn how to build and connect a custom Model Context Protocol (MCP) server to Google Antigravity 2.0 to expose proprietary databases and APIs as agent tools.
Out of the box, Google Antigravity 2.0 is equipped with core tools for reading files, running shell scripts, and conducting web searches. But in a real-world enterprise codebase, agents need access to custom resources—such as internal API gateways, production error tracking logs, or proprietary database schemas.
To allow agents to communicate with any software resource, Antigravity integrates with the Model Context Protocol (MCP).
In this tutorial, we will build a custom MCP server in Python and connect it directly to Antigravity as a brand new agent tool.
Quick Answer: To connect a private API or internal tool to Google Antigravity, write a small MCP server (FastMCP in Python is ~20 lines: declare tools with the
@mcp.tool()decorator, docstrings describe when the agent should call them), then register it in~/.gemini/antigravity/mcp_config.jsonundermcpServers. Antigravity auto-discovers the tools on startup — no agent code changes needed.
What is Model Context Protocol (MCP)?
Model Context Protocol is an open-source protocol developed to standardize how LLM-powered applications interact with external tools and data sources. Think of it as the USB-C port for AI agents.
Instead of writing custom API integration code for every tool, you write a standard MCP server. Any MCP-compatible agent (like Antigravity or Claude Code) can instantly discover its available tools and schemas.
Step 1: Building a Custom MCP Server in Python
We will write a simple MCP server that queries a local system monitor (CPU and RAM metrics) and exposes this diagnostic data to our coding agent.
First, initialize a new Python file mcp_sysmon.py and install the MCP Python SDK:
pip install mcp
Now, write the server code:
# mcp_sysmon.py
import psutil
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP Server
mcp = FastMCP("SystemMonitor")
@mcp.tool()
def get_system_metrics() -> str:
"""
Retrieves current CPU and Memory usage metrics from the developer's machine.
"""
cpu_percent = psutil.cpu_percent(interval=1)
memory = psutil.virtual_memory()
return (
f"CPU Usage: {cpu_percent}%\n"
f"Memory Usage: {memory.percent}% (Used: {memory.used / (1024**3):.2f} GB / Total: {memory.total / (1024**3):.2f} GB)"
)
if __name__ == "__main__":
mcp.run()
This short script declares a tool get_system_metrics. The docstring is critical: the LLM reads the docstring to understand when and how to invoke this tool.
Step 2: Registering the Server in Antigravity
Antigravity resolves its MCP servers through the global config file or project-specific configurations. To register our new server, add it to your configuration directory:
Open or edit ~/.gemini/antigravity/mcp_config.json:
{
"mcpServers": {
"system-monitor": {
"command": "python",
"args": [
"/absolute/path/to/mcp_sysmon.py"
]
}
}
}
Step 3: Verifying the Tool
Start your Antigravity agent CLI. Once initialized, the agent will dynamically query the registered server. You can verify it by running a prompt:
Developer: "Can you check if my local system has enough memory available to run the test suite?"
Antigravity will identify that CPU/RAM metrics are needed, execute the get_system_metrics tool via the MCP protocol, and output the diagnostics directly in your shell:
[system-monitor/get_system_metrics] Invoked.
-> CPU Usage: 14.5%
-> Memory Usage: 62.4% (Used: 9.98 GB / Total: 16.00 GB)
The agent will respond:
"Yes, you have 6.02 GB of free memory, which is ample to execute the local testing suite."
Conclusion: Designing Custom Agents
With MCP, the barrier to teaching AI agents about your custom corporate tools is completely gone. By packaging databases, APIs, or custom script suites into MCP endpoints, you turn Antigravity into a specialized, domain-expert engineer for your specific stack.
Explore the Complete Google Antigravity Guide Series
Reuse: licensed under CC BY 4.0 — quoting, summarizing, and republishing is permitted with attribution.
Cite as: “Connecting Custom Tools: Exposing Private APIs via Custom MCP Servers,” AI Dev Hub, https://aidevhub.net/blog/google-antigravity-mcp-custom-tools
Markdown for AI/LLM consumption: /blog/google-antigravity-mcp-custom-tools.md · full corpus: /llms-full.txt
Related Content
Articles
Google Antigravity Cost & Latency Estimates: How Much a Task Really Costs (and How to Measure It Yourself)
Transparent cost & latency estimates for Google Antigravity 2.0 tasks on a ~200-file Next.js project — single-file refactors, multi-file cascades, and TDD loops — plus a step-by-step method to measure your own real numbers.
Read moreBeyond Autocomplete: Transition to Autonomous Software Engineers
Explore the evolution of AI-powered development, comparing autocomplete tools like Cursor with autonomous coding agents like Google Antigravity 2.0.
Read moreHow to Write Google Antigravity Custom Rules: agents.md, .rules, Strict Mode & Allow Lists (2026 Guide)
Learn how to write custom rules for Google Antigravity 2.0: where agents.md and .rules files go, how rule resolution works, and copy-paste configs for strict mode, allow lists, turbo mode, and auto-retry.
Read moreRelated Tools
Claude-code-mcp
MCP server providing privileged code execution capabilities to Claude Code, enabling bypass-restricted operations for advanced development workflows.
View toolClaudecode-gemini-mcp
MCP server that routes Claude Code requests through Google Gemini models for multi-model code review and cross-referencing.
View toolCode-sandbox-mcp
MCP server that provisions sandboxed execution environments for LLMs to safely run untrusted code in isolated containers.
View toolRelated Workflows
AI-Powered Code Review Workflow
Use AI tools to automate and improve your code review process
View workflowBuilding with MCP: Server Development Workflow
Step-by-step workflow for creating and deploying MCP servers
View workflowChatGPT Prompt Engineering Workflow
Master prompt engineering techniques to get the best results from ChatGPT
View workflow