Concept 6 · Google · AI Community 2026What is MCP (Server Side)?
05b and 05d · Art #5b and #5d

What if the highway stops database in BigQuery is owned by an external infrastructure team that changes table schemas every quarter?

The problem with direct tools: embedding raw BigQuery SQL inside your agent repository couples your agent lifecycle to an external database.

The MCP solution: wrap the external database query in a standalone MCP Server (@mcp.tool()).

Dual transport: run over stdio locally (05b) or expose over HTTP SSE (port=8002 in 05d) so any authorized agent can discover and call tools dynamically!

Logging: MCP stdio servers communicate over stdout, so all logs MUST go to stderr.

MCP: the USB-C between agents and data
suggeritore_agent_bq_mcp_soste_tool.py (Branch 05d)
from mcp.server.mcpserver import MCPServer
from google.cloud import bigquery
logging.basicConfig(level=logging.INFO,
format="%(levelname)s: %(message)s",
stream=sys.stderr,)
mcp = MCPServer("Soste_BigQuery_MCP_Server")
# mcp = MCPServer("BigQuery-Soste-Server")
@mcp.tool()
def find_soste_by_fuel_and_location(
candidate_stops: list[str], fuel_type: str
) -> dict:
"""Queries BigQuery db_soste for stops matching fuel/EV needs."""
rows = bq_client.query(sql, job_config=cfg).result()
return {"status": "success",
"matched_stops": [dict(r) for r in rows]}
if __name__ == "__main__":
# from STDIO to SSE so it runs as a persistent
mcp_port = int(os.getenv("MCP_PORT", "8002"))
# mcp.run(transport="stdio")
mcp.run(transport="sse", host="127.0.0.1", port=mcp_port)