graph-tool-call
This server enables tool discovery and execution by building a graph-based index of API tools, allowing you to efficiently find and call the right tools.
Search for tools (
search_tools): Find relevant tools using natural language queries with hybrid retrieval (BM25 + graph traversal + embedding); supports pagination (top_k,page) and deprioritizes previously called tools.Get tool schema (
get_tool_schema): Retrieve the full parameter/schema details for a specific tool by name, typically used after searching to prepare for execution.List categories (
list_categories): Browse all tool categories in the loaded graph along with their tool counts.View graph info (
graph_info): Get summary statistics about the tool graph, including tool count, node/edge counts, and category breakdowns.Execute tools (
execute_tool): Send real HTTP requests to OpenAPI-defined endpoints by providing the tool name, arguments (as a JSON string), a base URL, and an optional auth token.Load additional sources (
load_source): Dynamically add more tools from OpenAPI spec URLs (JSON/YAML), Swagger UI pages, or local file paths to expand the tool graph at runtime.
Supports ingesting GitHub API tool definitions to manage complex workflows and reduce context usage in repository and issue management scenarios.
Ingests Kubernetes API definitions to build a tool graph, enabling high-accuracy tool retrieval and significant token reduction for complex K8s management tasks.
Provides a dedicated integration for LangChain, allowing developers to incorporate tool graph retrieval and workflow guidance into LangChain-based agents.
Integrates with Ollama to provide semantic embedding similarity for tool retrieval, enabling cross-language and semantic search capabilities.
Connects to OpenAI for semantic embedding search and supports ingesting OpenAI-compliant tool definitions to facilitate workflow-aware tool selection.
Automatically ingests tool definitions from Swagger and OpenAPI specifications to construct relationships and suggest multi-step execution workflows.
Supports parsing and ingesting tool definitions from YAML-based OpenAPI specifications to build the internal tool graph.
graph-tool-call
Graph-structured retrieval for large LLM tool catalogs.
Find the target tool, the prerequisite tools that produce its inputs, and the smallest schema bundle that fits the planner's token budget.
Documentation · Quickstart · PyPI · Benchmarks
English · 한국어
The Problem
A semantic search for "refund an order" can find refundOrder. That is not
enough when the operation requires an order_id that the user does not have.
A usable candidate set also needs the operation that produces that field:
findOrdersByEmail(email) -> order_id -> refundOrder(order_id)Large catalogs create a second problem: sending every schema to the model wastes context and can lower selection quality. graph-tool-call treats retrieval as a contract-aware graph problem instead of flat similarity search.
It provides:
deterministic ingestion from OpenAPI, GraphQL introspection, MCP tools, Python functions, and structured tool catalogs;
hybrid target retrieval with keyword, graph, optional embedding, and MCP annotation signals;
evidence-backed target selection and typed prerequisite expansion;
token-budgeted, contract-projected schemas for the model-facing catalog;
readiness, failure, and trace metadata for application-side diagnostics;
adapters for OpenAI, Anthropic, LangChain v1, MCP, Docker, and Kubernetes.
Authentication, tenant policy, approval, and product-specific execution remain in the host application.
Related MCP server: mcptool
See It in 30 Seconds
No model, API key, or network call is required:
uvx graph-tool-call demo dependency-chainSelected target:
refundOrder(order_id)
Required producer:
findOrdersByEmail(email) -> order_id
evidence: api_contract, openapi_link
Execution order:
1. findOrdersByEmail
2. refundOrder
Planner context:
6 catalog tools -> 2 required tools
estimated tokens: 1476 -> 160 (89% fewer)This demo runs the real retriever, deterministic target selector, typed dependency closure, and schema admission pipeline.
Installation
The core search and graph package uses only the Python standard library. Optional integrations are installed explicitly:
pip install graph-tool-call
pip install "graph-tool-call[openapi]" # YAML OpenAPI documents
pip install "graph-tool-call[korean]" # Kiwi tokenizer
pip install "graph-tool-call[langchain]" # LangChain v1 middleware
pip install "graph-tool-call[mcp]" # MCP server and proxy
pip install "graph-tool-call[all]" # all optional featuresPython 3.10 through 3.14 are tested in CI.
Build and Search
OpenAPI
from graph_tool_call import ToolGraph
graph = ToolGraph.from_url(
"https://petstore3.swagger.io/api/v3/openapi.json",
cache="petstore.graph.json",
)
for result in graph.retrieve_with_scores("create a new pet", top_k=5):
print(result.tool.name, result.score, result.confidence)OpenAPI ingestion preserves request and response schemas, parameter locations,
content types, security requirements, links, examples, response envelopes, and
typed consumes/produces contracts. Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1
are supported.
Inspect a collection before exposing it to an agent:
graph-tool-call inspect-openapi ./openapi.json --json
graph-tool-call build-openapi-collection ./openapi.json -o collection.jsonThe report contains stable readiness issue codes, semantic coverage, and edge quality rather than a single opaque score.
Other sources
from graph_tool_call.ingest import ingest_source
openapi_result = ingest_source(openapi_document)
graphql_result = ingest_source(introspection_result)
mcp_result = ingest_source({"tools": mcp_tools}, format_hint="mcp-tools")
python_result = ingest_source([read_file, write_file])Every adapter returns normalized ToolSchema objects, capability metadata, and
structured unsupported-feature diagnostics.
Choose an Integration
Environment | Recommended surface | What graph-tool-call owns |
Python application |
| ingest, search, evidence, dependency closure |
OpenAI Responses or Chat Completions |
| per-request function-tool filtering |
Anthropic Messages |
| per-request tool filtering |
LangChain v1 |
| model-call tool selection |
Claude Code, Cursor, Windsurf | MCP proxy | many MCP backends behind 3 gateway tools |
OpenAI Agents, PydanticAI, Google ADK | remote MCP server | protocol-neutral search service |
Docker or Kubernetes | Streamable HTTP MCP | private deployable service |
See the compatibility matrix for validation boundaries. Protocol compatibility does not imply that every framework or cloud release is tested by this repository.
OpenAI Responses
from graph_tool_call.middleware import patch_openai
patch_openai(client, graph=graph, top_k=5)
response = client.responses.create(
model=model_name,
input="delete a user account",
tools=all_function_tools,
)Hosted tools such as web search pass through unchanged. The same patch keeps legacy Chat Completions support.
LangChain v1
from langchain.agents import create_agent
from graph_tool_call.langchain import create_tool_selection_middleware
selection = create_tool_selection_middleware(langchain_tools, top_k=5)
agent = create_agent(
model,
tools=langchain_tools,
middleware=[selection],
)The middleware intersects with tools still allowed by earlier permission or feature-flag middleware; it does not reintroduce filtered tools.
MCP server
graph-tool-call ingest ./openapi.json -o graph.json
graph-tool-call serve \
--graph graph.json \
--transport streamable-http \
--host 127.0.0.1 \
--port 8000The MCP endpoint is /mcp; HTTP deployments also expose /healthz and
/readyz. Keep remote endpoints private or behind an authenticated gateway.
MCP proxy
graph-tool-call proxy \
--config ./mcp-backends.json \
--transport streamable-httpThe proxy accepts local stdio, SSE, and Streamable HTTP backends. In gateway
mode it exposes search_tools, get_tool_schema, and call_backend_tool, then
notifies capable clients when matching backend tools become visible.
Reproducible Evidence
The release headline is deliberately model-free and small enough to replay in CI. On seven curated commerce cases, adding typed producer expansion to the same selected target produced:
Metric | Target only | Target + graph producers |
Required-producer recall | 14.3% | 100% |
Candidate plan coverage | 47.6% | 100% |
Candidate binding support | 14.3% | 100% |
Target Recall@5 | - | 100% |
The case-level v0.47.0 artifact records fixture hashes, every expected target and producer, and replay commands:
make launch-evidence
make launch-evidence-checkThe separate
observability artifact
checks that tracing leaves engine inputs unchanged, replays deterministically,
scrubs secrets, explains every decision, and stays below the documented
5ms/span p95 capture-cost gate:
make observability-evidence-checkThis is an engine regression suite, not a population-level estimate of LLM tool-calling accuracy and not a state-of-the-art claim. Larger external comparisons, model-loop experiments, confidence intervals, and known weak cases are reported in Benchmark Results and the paper protocol.
Production Boundary
graph-tool-call is the retrieval and contract layer. A production adapter still owns:
user and service authentication;
tenant authorization and approval policy;
downstream secrets and cookie handling;
side-effect confirmation, cleanup, and audit retention;
provider/model lifecycle and final response policy.
Do not store raw credentials in graph artifacts, tool descriptions, trace records, or model-visible arguments.
Documentation
Start here | Purpose |
first search, graph, readiness, and execution loop | |
understand the pipeline and boundaries | |
contract extraction and collection build | |
ranking evidence and deterministic guard | |
frameworks, MCP, and deployment | |
stable public Python surface | |
current product and research priorities |
Development
git clone https://github.com/SonAIengine/graph-tool-call.git
cd graph-tool-call
poetry install --with dev --all-extras
poetry run ruff check .
poetry run ruff format --check .
poetry run pytest tests/ -qSee CONTRIBUTING.md and the release checklist.
License
Available Tools
6 toolsexecute_toolA
Execute an OpenAPI tool via HTTP.
Sends the actual HTTP request based on the tool's method and path
from the OpenAPI spec. Use after search_tools() + get_tool_schema()
to call the API.
Args:
tool_name: Exact tool name (as returned by search_tools)
arguments: JSON string of parameter values (e.g. '{"owner":"me","repo":"test"}')
base_url: API base URL (e.g. https://api.github.com). Required if not inferrable.
auth_token: Bearer token for authentication (optional)
Inputs: arguments (required), tool_name (required), base_url, auth_token. Returns: result
get_tool_schemaA
Get the full schema of a specific tool by name.
Use this after search_tools() to get complete parameter details
for a tool you want to call.
Args:
name: Exact tool name (as returned by search_tools)
Inputs: name (required). Returns: result
graph_infoA
Show summary statistics about the loaded tool graph.
Returns tool count, node count, edge count, and category breakdown.
Inputs: no named parameters. Returns: result
list_categoriesA
List all tool categories in the graph.
Returns categories with their tool counts, useful for understanding the available tool landscape before searching.
Inputs: no named parameters. Returns: result
load_sourceB
Load additional tools from an OpenAPI spec URL or file path.
Supports:
- Direct spec URLs (JSON/YAML): https://api.example.com/openapi.json
- Swagger UI URLs: https://api.example.com/swagger-ui/index.html
- Local file paths: ./openapi.json, /path/to/spec.yaml
Args:
source: OpenAPI spec URL or local file path
Inputs: source (required). Returns: result
search_toolsA
Search for relevant tools by natural language query.
Returns the most relevant tools for the given query, ranked by
graph-based hybrid retrieval (BM25 + graph traversal + embedding).
Previously called tools are automatically deprioritized to surface
new candidates on repeated searches.
Args:
query: Natural language description of what you want to do.
Examples: "user authentication", "delete a file",
"manage shopping cart items"
top_k: Maximum number of tools to return per page (default: 5)
page: 1-based page for browsing beyond the first results. The
response carries ``page`` and ``has_more`` so you can decide
whether to request the next page.
Inputs: query (required), page, top_k. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool serves a distinct role: search_tools for discovery, get_tool_schema for inspection, list_categories and graph_info for overview, execute_tool for execution, and load_source for ingestion. No two tools overlap in functionality, making selection unambiguous.
Most tool names follow a consistent verb_noun snake_case pattern (search_tools, get_tool_schema, list_categories, execute_tool, load_source). The sole deviation is graph_info, which uses noun_noun instead of verb_noun, but it remains clear and stylistically consistent.
With 6 tools, the set is well-scoped for a tool-graph management server. Each tool supports a distinct step in the workflow (load, discover, inspect, execute, overview), and there is no bloat or sense of missing essentials.
The core workflow is complete: load_source brings in new tools, search_tools discovers them, get_tool_schema inspects them, and execute_tool runs them. list_categories and graph_info provide useful overview. The only minor gap is the absence of a direct 'list all tools' function, but search_tools with a broad query can cover that.
Maintenance
Related MCP Connectors
Graph-native persistent memory for AI agents — 33 MCP tools, zero-LLM writes.
Stateless agentic tools over MCP: concept extraction, long-context, knowledge graph, planning.
Cloud or self-hosted knowledge for AI agents: hybrid search, reranking, GraphRAG, scoped MCP tools.
LLM Orchestration Agent (Mcp)
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceA high-performance Go-based MCP server that provides a microservice architecture for orchestrating diverse tools through gRPC and HTTP/REST APIs. Enables seamless integration of language-agnostic tools including ML capabilities, web search, calculations, and human interaction for intelligent agent workflows.2-
- AlicenseNot gradedqualityNot gradedmaintenanceA drop-in MCP proxy that aggregates multiple backend servers into two meta-tools for efficient tool discovery and execution. It enables AI clients to access hundreds of tools while minimizing context window usage through searchable indexing.1 npm-
- -licenseNot gradedqualityNot gradedmaintenanceMCP proxy server with semantic tool search for LLM coding agents. It reduces context window usage by activating only relevant tools based on user queries.-
- AlicenseNot gradedqualityBmaintenanceA context-aware MCP proxy that reduces token usage by exposing only 3 tools (mcp_search, mcp_call, mcp_schema) to LLMs, with on-demand tool loading and BM25 search.152 npm2MIT