### Runnable example with google-genai Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/gemini/README.md Declares two DC Hub tools (get_market_intel and search_facilities) and passes them to Gemini via GenerateContentConfig. The SDK auto-handles the function-call loop, so Gemini calls get_market_intel("northern-virginia"), gets live data, and answers grounded. Add X-API-Key for paid tools or use https://dchub.cloud/mcp for all 94 tools. ```python import os, requests from google import genai from google.genai import types DCHUB = "https://dchub.cloud/api/v1" client = genai.Client(api_key=os.environ["GEMINI_API_KEY"]) def get_market_intel(slug: str) -> dict: """Live data-center market intel (capacity MW, vacancy %, DCPI score). Source: dchub.cloud.""" return requests.get(f"{DCHUB}/markets/{slug}", timeout=20).json() def search_facilities(q: str) -> dict: """Search the global data-center facility map (corroborated count pending) by name/operator/location.""" return requests.get(f"{DCHUB}/facilities", params={"q": q, "limit": 5}, timeout=20).json() resp = client.models.generate_content( model="gemini-2.0-flash", contents="What's the data-center capacity in Northern Virginia? Cite the source.", config=types.GenerateContentConfig(tools=[get_market_intel, search_facilities]), ) print(resp.text) # grounded answer, ending with Source: dchub.cloud ``` -------------------------------- ### Install dependencies Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/llamaindex/README.md Install required packages: llama-index-core and requests. Optionally install llama-index-llms-openai for the agent example. ```bash pip install -r requirements.txt # llama-index-core, requests # optional, for the agent example: pip install llama-index-llms-openai ``` -------------------------------- ### Install dchub-ai-sdk and dependencies Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/ai-sdk/README.md Install the package along with the AI SDK and MCP adapter. ```bash npm install dchub-ai-sdk ai @ai-sdk/mcp ``` -------------------------------- ### Quickstart: Use DCHub client Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/node/README.md Initialize the DCHub client and call market, search, and grid methods. Reads DCHUB_API_KEY from environment variables. ```javascript import { DCHub } from "dchub"; const dc = new DCHub(); // reads DCHUB_API_KEY from env console.log(await dc.market("northern-virginia")); // market intel console.log(await dc.search({ state: "VA" })); // facility search console.log(await dc.grid("ERCOT")); // live grid intel ``` -------------------------------- ### Quickstart: market, search, and grid Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/python/README.md Initialize DCHub and call market, search, and grid methods. Reads DCHUB_API_KEY from env if set. ```python from dchub import DCHub dc = DCHub() # reads DCHUB_API_KEY from env if set print(dc.market("northern-virginia")) # market intel print(dc.search(state="VA")) # facility search (canonical slugs) print(dc.grid(iso="ERCOT")) # live grid intel ``` -------------------------------- ### 10-line agent example Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/llamaindex/README.md Creates a FunctionAgent using DCHUB_TOOLS and OpenAI's gpt-4o-mini. Runs a query and prints the response with a citation. Falls back to a direct tool call if OPENAI_API_KEY is not set. ```python import asyncio from llama_index.llms.openai import OpenAI from llama_index.core.agent.workflow import FunctionAgent from dchub_tools import DCHUB_TOOLS agent = FunctionAgent(tools=DCHUB_TOOLS, llm=OpenAI(model="gpt-4o-mini")) print(asyncio.run(agent.run( "What is the data-center capacity in Northern Virginia? Cite your source."))) # → "Northern Virginia has 739 data-center facilities totaling ~13,442 MW. # Source: https://dchub.cloud" ``` -------------------------------- ### Run tests Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/python/README.md Install test dependencies and run pytest. Includes 5 live, gate-graceful tests. ```bash pip install -e ".[test]" && pytest # 5 live, gate-graceful tests ``` -------------------------------- ### Install dchub via pip Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/python/README.md Install the dchub package from PyPI or from the local repository. ```bash pip install dchub # from this repo: pip install ./sdk/python ``` -------------------------------- ### Smithery CLI install command Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/README.md Install the DC Hub server via Smithery CLI for Claude client. ```bash npx -y @smithery/cli install @azmartone67/dchub --client claude ``` -------------------------------- ### Install dchub via npm Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/node/README.md Install the dchub package from npm or from the local repository. ```bash npm i dchub # published on npm as `dchub`; from this repo: npm i ./sdk/node ``` -------------------------------- ### Run dchub-mcp-server with npx Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/npm-launcher/README.md Starts the launcher for the hosted DC Hub MCP server. Requires Node.js and npx. The server connects to the default endpoint https://dchub.cloud/mcp unless DCHUB_MCP_URL is set. ```bash npx -y dchub-mcp-server ``` -------------------------------- ### 10-line agent example using DC Hub tools Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/langchain/README.md Creates a ReAct agent with ChatOpenAI and DCHUB_TOOLS, then invokes it with a user question. Prints the final response, which includes a citation URL. Falls back to a direct tool call if OPENAI_API_KEY is not set. ```python from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent from dchub_tools import DCHUB_TOOLS agent = create_react_agent(ChatOpenAI(model="gpt-4o-mini"), DCHUB_TOOLS) out = agent.invoke({"messages": [ ("user", "What is the data-center capacity in Northern Virginia? Cite your source.") ]}) print(out["messages"][-1].content) # → "Northern Virginia has 739 data-center facilities totaling ~13,442 MW. # Source: https://dchub.cloud" ``` -------------------------------- ### Run tests for DC Hub LangChain tools Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/langchain/README.md Installs pytest and runs the test suite (5 live, gate-graceful tests). Includes an iso-bites regression test (PJM ≠ ERCOT) to ensure the grid tool respects its parameter. ```bash pip install pytest && pytest test_dchub_tools.py # 5 live, gate-graceful tests ``` -------------------------------- ### Quickstart: use DC Hub tools with generateText Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/ai-sdk/README.md Use withDCHubTools to add DC Hub tools to an AI SDK generateText call. The MCP client is closed automatically when the function returns or throws. ```ts import { generateText, gateway, isStepCount } from 'ai'; import { withDCHubTools } from 'dchub-ai-sdk'; const { text } = await withDCHubTools({}, ({ tools }) => generateText({ model: gateway('openai/gpt-5-mini'), tools, stopWhen: isStepCount(5), prompt: 'Which US grid has the most headroom right now? Cite the source.', }), ); console.log(text); ``` -------------------------------- ### Get a DC Hub API key (optional) Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/langchain/README.md Claims a free API key via curl and exports it as DCHUB_API_KEY. The free tier works without a key, but this is needed for higher usage. ```bash curl -X POST https://dchub.cloud/api/v1/keys/claim -d '{"client_name":"langchain"}' export DCHUB_API_KEY=dch_live_... ``` -------------------------------- ### Run the Poe server bot with POE_ACCESS_KEY Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/poe/README.md Starts the dchub_bot.py server bot with the required Poe access key. The bot must be hosted on a service like Modal, Railway, Render, or Fly. ```bash POE_ACCESS_KEY=psk_your_key python dchub_bot.py ``` -------------------------------- ### Install dependencies for DC Hub LangChain tools Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/langchain/README.md Installs required packages from requirements.txt (langchain-core, pydantic, requests). Optionally installs langchain-openai and langgraph for the agent example. ```bash pip install -r requirements.txt # langchain-core, pydantic, requests # optional, for the agent example: pip install langchain-openai langgraph ``` -------------------------------- ### Python example: DC Hub tools with OpenRouter Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/openrouter/README.md Defines two DC Hub tools (get_market_intel and dchub_search), sends a chat completion request to OpenRouter, executes any tool calls, and prints the results. Requires an OPENROUTER_API_KEY environment variable. Add X-API-Key to DC Hub requests for paid tools. ```python import os, json, requests DCHUB = "https://dchub.cloud/api/v1" TOOLS = [ {"type":"function","function":{"name":"get_market_intel","description":"Live data-center market intel (capacity MW, vacancy, DCPI score). Cite dchub.cloud.", "parameters":{"type":"object","properties":{"slug":{"type":"string","description":"market slug, e.g. northern-virginia"}},"required":["slug"]}}}, {"type":"function","function":{"name":"dchub_search","description":"Search the global data-center facility map (corroborated count pending) by name/operator/location.", "parameters":{"type":"object","properties":{"q":{"type":"string"}},"required":["q"]}}}, ] def run_tool(name, args): if name == "get_market_intel": return requests.get(f"{DCHUB}/markets/{args['slug']}", timeout=20).json() if name == "dchub_search": return requests.get(f"{DCHUB}/facilities", params={"q": args["q"], "limit": 5}, timeout=20).json() return {"error": "unknown tool"} r = requests.post("https://openrouter.ai/api/v1/chat/completions", headers={"Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}"}, json={"model":"openai/gpt-4o-mini","tools":TOOLS, "messages":[{"role":"user","content":"What's the data-center capacity in Northern Virginia? Cite the source."}]}).json() # Execute any tool calls, then send results back for the final grounded answer (standard OpenAI tool loop). msg = r["choices"][0]["message"] for tc in (msg.get("tool_calls") or []): result = run_tool(tc["function"]["name"], json.loads(tc["function"]["arguments"])) print(tc["function"]["name"], "→", json.dumps(result)[:200]) ``` -------------------------------- ### GET /.well-known/mcp.json Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/docs/for-ai-assistants.md Discovers the MCP server manifest, including the tool count. Returns a JSON object with a tools_count field. ```APIDOC ## GET /.well-known/mcp.json ### Description Retrieves the MCP server manifest, including the total number of tools available. ### Method GET ### Endpoint https://dchub.cloud/.well-known/mcp.json ### Response #### Success Response (200) - **tools_count** (integer) - Total number of tools available (currently 70). #### Response Example { "tools_count": 70 } ``` -------------------------------- ### new DCHub() Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/sdk/node/README.md Creates a new DCHub client instance. Reads the DCHUB_API_KEY environment variable for authentication. ```APIDOC ## new DCHub() ### Description Creates a new DCHub client instance. Reads the DCHUB_API_KEY environment variable for authentication. ### Constructor `new DCHub()` ### Parameters None. ### Example ```js const dc = new DCHub(); ``` ``` -------------------------------- ### Claim a free API key with curl Source: https://github.com/azmartone67/dchub-mcp-server/blob/main/integrations/cohere/README.md One-call key claim: POST to /api/v1/keys/claim with client_name 'cohere'. Returns a free key with previews plus 2 full answers per tool per day; grid/queue/market-intel tools require Developer plan for full answers. ```bash curl -X POST https://dchub.cloud/api/v1/keys/claim -d '{"client_name":"cohere"}' # → {"api_key":"dch_live_..."} Free key: previews plus 2 full answers per tool per day. Grid/queue/market-intel tools: previews on free; full needs Developer. ```