Skip to main content

SchemaRouter

When tools speak different schemas, put a typed capability boundary in between.

English · 한국어 · Docs · Examples · Contributing · Latest release

CI Docs CodeQL Security Audit PyPI Python MIT

Stable release: 0.17.0 · Beta / pre-1.0

SchemaRouter is a typed capability retrieval and schema-aware execution layer for LLM/RAG agents.

It sits between an orchestrator and external tools/data sources, compiles heterogeneous schemas into one capability model, retrieves a bounded candidate set, and validates the selected call again at execution time. It is not an agent framework, identity provider, database proxy, or LLM gateway.

pip install schemarouter

Why SchemaRouter

A normal tool router mainly answers which tool should I call? SchemaRouter also keeps track of which endpoint, parameters, output fields, schema version, access path, policy, and execution binding make that call valid.

user query
  -> required semantic fields
  -> bounded capability candidates
  -> endpoint + parameters + output fields
  -> policy / availability / schema validation
  -> trusted execution
  -> projected typed result

This is useful when a catalog mixes APIs, MCP servers, SDKs, databases, and framework tools whose names overlap but whose schemas and execution constraints differ.

Concepts → · Capability retrieval → · Execution boundary →

Quickstart

Provider-first onboarding lets an application start from the service it wants rather than knowing every underlying protocol first.

import asyncio

from schemarouter import PlanRequest, SchemaRouter


async def main():
    router = SchemaRouter()

    async with router:
        registration = await router.add_provider("apis-guru")
        tool = router.registry.get(registration.registered_tool_keys[0])

        plan = router.plan(
            PlanRequest(
                query="API directory metrics total number of APIs",
                preferred_tools=[tool.key],
                max_calls=1,
            )
        )

        result = (await router.execute(plan))[0]
        print(result.tool, result.endpoint, result.data["numAPIs"])


asyncio.run(main())

The flow is:

provider identity → schema/adaptor resolution → typed capability registration → bounded selection → validated execution → typed result

Quickstart → · Runnable examples →

Where it fits

flowchart LR
    Q["User"] --> A["Agent / RAG / application"]
    A --> SR["SchemaRouter"]
    SR --> S["APIs / MCP / SDKs / databases"]
    S --> SR
    SR --> A

The surrounding application owns conversation, decomposition, memory, checkpoints, and final generation. SchemaRouter owns the registered capability and execution boundary.

Retrieval is side-effect free:

candidates = router.retrieve("current Young's modulus for MAT-7", k=5)

for candidate in candidates.candidates:
    print(candidate.route_id, candidate.output_fields)

Use retrieve_executable(...) when the shortlist must also have a currently valid execution binding.

Connect tools and data

SchemaRouter supports several ingress families behind the same capability model.

Family Typical entry points
Provider identity await router.add_provider(...)
Typed Python / ToolSpec add_callable(...), add_tool(...), add_bound_tool(...)
API protocols OpenAPI, MCP, OPTIMADE, GraphQL, OData, OpenRPC
Relational databases SQLite, caller-owned SQLAlchemy Engine
Vector databases Qdrant, Milvus, Pinecone, Weaviate, Chroma, PostgreSQL/pgvector
Graph / RDF Neo4j, Neptune, ArangoDB, FalkorDB, SPARQL
Document / search / KV / time-series MongoDB, Elasticsearch/OpenSearch, DynamoDB, Cosmos DB, Couchbase, ClickHouse, InfluxDB
Framework bridges LangChain, LangGraph, LlamaIndex

Credentials, connection pools, database clients, and transport state remain caller-owned. Vendor query languages are not exposed as model authority.

Choose an ingestion path → · Full ingestion matrix → · Provider-first registration → · Enterprise data onboarding →

Authorization and enterprise data

SchemaRouter consumes a verified PrincipalContext from the host application and can apply deny-by-default RBAC/ABAC before retrieval and again at execution.

The same policy model can narrow:

  • visible tools/endpoints;
  • database tables and fields;
  • trusted row/tenant filters;
  • vector metadata filters;
  • document/search fields;
  • graph relationships and hop depth.

SchemaRouter does not authenticate users and does not replace database-native roles, grants, RLS, ACLs, or network controls.

Authorization → · Database onboarding →

Execution boundary

A retrieved candidate or model choice never grants authority by itself. Before a result crosses the runtime boundary, SchemaRouter can revalidate:

  • tool/endpoint/schema fingerprints;
  • arguments and JSON Schema contracts;
  • principal policy and data scope;
  • current execution binding and availability;
  • raw output schema;
  • final field projection.

Remote mutation/destructive operations fail closed unless explicitly authorized by local policy.

Security model → · Trust and release evidence →

Stability

SchemaRouter 0.17.0 is Beta / pre-1.0. Public APIs may still evolve, but breaking changes are documented and release-gated.

Python 3.10–3.14 are release-blocking targets. Python 3.15 is a preview target.

Research benchmarks are kept separate from stable product guarantees. Experimental retrieval profiles or ranking methods are not promoted solely because one benchmark improves.

Versioning policy → · Research status → · Changelog →

Documentation

Topic Guide
Installation and first use Getting started
Architecture and concepts What SchemaRouter is
Provider/API ingestion Connect guides
Enterprise databases and access scope Enterprise data onboarding
Runtime policy and authorization Authorization
Operational inspection Inspection
Public API Reference
Research evidence Research index

Full documentation: https://jdeun.github.io/SchemaRouter/

Scope

SchemaRouter deliberately does not own agent loops, final answer generation, identity authentication, credential storage, or arbitrary database/query execution. Those remain outside the capability boundary.

License

MIT. See LICENSE.

Metadata

Release files for schemarouter 0.17.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schemarouter 0.17.0
File Size Uploaded
schemarouter-0.17.0.tar.gz 1.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for schemarouter 0.17.0
File Interpreter ABI Platform
schemarouter-0.17.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.3 MB

Release files / schemarouter-0.17.0.tar.gz

Download URL schemarouter-0.17.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
3a632d6f6e560216c7147a0136cc9766b427f8e9bbe6fafa336a32bdd672e3f5
BLAKE2b-256 checksum
How to use checksums
512b42fba7db93f0f00d960dce69749e1e93112cf8a920e39e2425a81eb6b5dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / schemarouter-0.17.0-py3-none-any.whl

Download URL schemarouter-0.17.0-py3-none-any.whl
Size 420.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd4648145ad62208f01ce2c50e9e52b910c6a1a3c2f5cbbd88a475ee19930f26
BLAKE2b-256 checksum
How to use checksums
65fbf091ddae231c86e75e9bbc6b0a576c69d08536fcbef7784e3b75a8e1e368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page