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.16.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.16.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.16.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.16.0
File Size Uploaded
schemarouter-0.16.0.tar.gz 1.6 MB Details

Built distribution (wheel)

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

Total release size: 2.0 MB

Release files / schemarouter-0.16.0.tar.gz

Download URL schemarouter-0.16.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
b98a56398386981feb5576f6ad508a12d592e35030f54414d32cd7c91ea95646
BLAKE2b-256 checksum
How to use checksums
c5bee0199a4225442afed32b9960bbe3272de786ac7bf9f78111eba58c09b412
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 4, 2026.

Transparency log

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

Download URL schemarouter-0.16.0-py3-none-any.whl
Size 335.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4836d8fdbead66f2c6b88b0c84037f122990e0d0f3957364121d26401d1052d5
BLAKE2b-256 checksum
How to use checksums
3bc1ecd253e357728cb04f67e7ac4a11bc02352f4c629263f14b82c3743d381c
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 4, 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