librarian

One librarian for every API your agents use.

Agents ask librarian for data instead of carrying their own API keys. It learns an API the first time one is needed, asks a person for the key once, serves reads within policy, and holds every write for a person's approval unless an approver decided in advance.

pip install librarian-a2a
docker pull ghcr.io/kultar/librarian:0.23.2

Open source, Apache-2.0. Alpha: expect breaking changes before 1.0.

release-notes agent support assistant triage bot A2A or MCP librarian policy engine with the key Jira GitHub internal APIs registry (database)what each API is,which operations are reads secret storekeys people add;agents see references peopleapprove what was learned,add keys, approve writes

See it run

One minute, from a real run on kagent. The agent's sandbox holds no credentials. It has librarian learn an API nobody set up, then asks for a change, which waits until a person approves it on librarian's page. Pauses while the model thinks are shortened; nothing is re-enacted.

What happens on a request

Nothing is set up per API in advance. The registry fills itself as agents need things, and a person is asked only when a key is missing or data would change.

  1. An agent asks for data from an API librarian doesn't know yet

    Over A2A or MCP, through a gateway such as LiteLLM or directly. The agent names the API and what it wants; it never names a host, so it can't point librarian anywhere else.

  2. librarian learns the API

    From its OpenAPI spec, else its documentation (found by itself if needed, with every extracted operation quote-checked against the page), else the model's own knowledge. Reads work at once; approvers are asked to review the entry, and approving makes it verified there and then.

  3. If the API needs a key, a person is asked once

    The agent's task waits and approvers get a Slack card. Someone follows the one-time link, signs in and pastes the key. It goes straight to your secret store, never through Slack, an agent or a model, and the task carries on by itself. When the API needs the person's own sign-in instead, the person behind the agent gets the link, signs in to the provider once, and every later request for them carries their own token.

  4. Writes wait for a person's approval

    The approval page shows exactly what will be sent: method, path, arguments and body. Approve once, allow similar writes with a narrow grant that lasts as long as the approver chooses, or decide once that an operation's writes are approved automatically, up to a daily cap and with one click back. DELETEs can only ever be approved one at a time. A write nobody has enabled yet is not refused silently: approvers get a card, enable the whole flow, and their decision is in effect at once.

How access is held

Three kinds of access, chosen per API, and none of them ever in an agent's hands.

A shared read-only key
Added once by an approver on a one-time page, straight into your secret store. Every agent's reads use it, within policy. Agents, logs and the model only see a reference like jira/readonly.
A separate write credential
Enabled by an approver, and used only after a person approves that exact write, a narrow grant covers it, or an approver chose automatic approval for that operation, capped per day. DELETE is never granted or automatic.
The person's own sign-in
For APIs where what you see depends on who you are: librarian is the OAuth client, each person signs in once in their browser, and every request their agents make for them carries their own token, so the API enforces their access. Tokens are stored per person, refreshed by librarian, never shown to agents, and a request for one person can never go out with another's token. People see and drop their own sign-ins in the console.

What people see

Agents talk to librarian over A2A or MCP. People get pages: a console for the people who run it, and one-time pages for the decisions only a person can make.

The console overview with tiles and the waiting list
The console: what librarian knows, and what waits on a person.
An API page with search, needs-attention operations and groups by tag
A large API: search, the operations needing a decision first, then groups by tag.
The Activity page: seven-day numbers, the busiest APIs and recent events
Activity: what agents did through librarian, and what it cost.
The enable page for a write flow: operations with ticks, the approval choice, the write credential choice
An agent wanted a write nobody had enabled: enable the whole flow, choose how writes are approved and where the write credential comes from.
The review page for a learned API
Approving a learned API from the Slack card: decide the open operations, then approve. It is verified at once.
A write approval page
Approving one write: method, path, arguments and body, nothing hidden. This agent runs on kagent with no person behind it, so its owner decides.
The approval page of a plan: six requests in order, each with its path and body, and the values that will come from an earlier step marked
Approving a plan: a commit and its pull request are six requests and one decision. Each is shown as it will be sent; what an earlier step will supply is marked.

What your agents save

librarian removes the overhead around an API call: tool bloat, rediscovery, oversized payloads, and the keys every agent would otherwise carry. It does not shrink an agent's own reasoning, and says so.

Seven tools instead of hundreds
An agent with direct access carries an API's tool definitions in its context on every request; GitHub's spec alone has 1,242 operations. Through librarian an agent sees seven tools and asks for the handful it needs.
Learning is paid once
Reading documentation, searching for it and extracting operations is the expensive model work. It runs once per API, with a model you choose for it, then serves every agent.
Most calls use no model at all
Running a known operation is plain code: policy check, HTTP call, provenance. A plain-language request costs one planner call, and a successful plan becomes a recipe replayed without the model.
Smaller answers
Field selection and a response-size cap return what the agent asked for, not a whole payload into its context. Pagination is handled on librarian's side.
Operations exist once
Credentials, rotation, retries, change detection and the audit trail live in one place instead of in every agent.
You can measure it
The audit log records every call with its byte count and whether a model was involved, so a week of real traffic shows the split between plain calls, recipes and planner calls.

Why it's safe to put between agents and your APIs

The design assumes that agents can be talked into anything. So nothing an agent, a document or a model says can change what librarian is allowed to do.

The model never decides
A deterministic policy engine with no LLM in it authorises every call. The optional planner can only plan reads and propose writes.
Credentials never travel through agents
Keys enter on a one-time page and go straight to the secret store. Agents, messages, logs and the model only ever see references like jira/readonly. If an API sends the key back in its answer, librarian removes it first.
Writes need a person
A verified registry entry, a separate write credential, and a human approval or a grant pinned to an agent, a person and an operation. Each write is sent once, with no redirects and an idempotency key, and claimed atomically so replicas never run it twice. A repeat with the same key, on any replica, gets the first result instead of a second run.
Untrusted input is fenced
The API host only ever comes from the caller's base_url, never from documentation or search results. Read versus write is decided by HTTP method. Search results are trust-ranked and third-party sites are skipped by default.
No way out to your network
An SSRF guard with DNS pinning refuses private addresses unless you allow them, redirects stay on the same origin, and response sizes are capped.
Agents can hold nothing at all
On Agent Substrate and kagent an agent's sandbox has no credentials, not even one for librarian. The platform's egress gateway signs each call with the agent's identity; librarian verifies it against the cluster's issuer, accepts only tokens minted for librarian, and gives the agent what a rule in its own config allows, never what the agent or its metadata claims.
Decisions are made in one place
What agents may do is decided by signed-in approvers on librarian's own pages and stored in its database, in effect on every replica at once. A GitHub repository receives a commit for every decision, saying who decided what, but it is only ever written to: nothing edited or merged there changes what agents may do.
Approval pages are locked down
A separate listener behind your SSO proxy, one-time HMAC links that expire, a strict content security policy with no external resources, and every decision recorded with who made it. The console on the same listener shows credential references only, and every action there is audited too.

The full threat model lists each threat and its mitigation.

In the stack you already run

librarian is one more server behind whatever already carries your agents' traffic. Nothing in that stack changes to try it, each way in has something to run, and the docs say how each is tested: by what, and how often.

  • Any MCP clientYou add one MCP server: librarian's address and the agent's key. Tested with every commit, by the official MCP SDK's client.
  • Any A2A clientYou add the address of librarian's agent card and the agent's key. Tested with every commit, by the official A2A SDK's client.
  • LiteLLMYou add an MCP server entry, an agent entry, or both. Tested every week against a real LiteLLM, and in a real deployment.
  • agentgatewayYou add two routes, or one value in librarian's chart on Kubernetes. Five minutes to try with Docker. Tested every week against agentgateway v1.7.0.
  • kagent and Agent SubstrateYou add a rule per Agent and one tools entry; agents hold no key at all. Ten minutes to try on kind. Tested by hand, with dates and versions in the docs.

Get started

Three paths, depending on where you are. Each one is documented step by step and has been followed end to end.

On your laptop

Ten minutes with Docker. You see an API learned on demand, a key asked for out of band, and a write held for approval.

git clone https://github.com/kultar/librarian
cd librarian/examples/quickstart
docker compose up -d
./ask '{"skill":"capabilities"}'
Getting started

For your team

A Helm chart with oauth2-proxy sign-in, Postgres for the registry and every decision, AWS Secrets Manager for keys, and a GitHub repository that receives a commit for each approved decision. Two or more replicas, no volumes, nothing exposed to the internet.

helm install librarian oci://ghcr.io/kultar/charts/librarian \
  --version 0.23.2 -n librarian -f values.yaml
helm test librarian -n librarian
Deploying for a team

Connect your agents

Behind LiteLLM's agent gateway and behind agentgateway librarian is both an MCP server and an A2A agent. On kagent and Agent Substrate agents need no key at all: the platform's gateway signs each call and librarian knows which agent it is. Any A2A or MCP client can also talk to it directly, and it is listed in the MCP Registry.

# LiteLLM config.yaml
mcp_servers:
  librarian:
    url: http://librarian.librarian.svc:8080/mcp
    transport: http
    auth_type: bearer_token
    auth_value: os.environ/LIBRARIAN_GATEWAY_KEY

# kagent, Agent Substrate
# (librarian's Helm values)
substrate:
  enabled: true
  rules:
    - match: {namespace: payments}
      write_apis: [github]
      owner: leads@example.com
    - match: {}   # the rest: reads
Integrations

What agents can ask for

The same six skills over A2A and as MCP tools (plus write_status and enable_status over MCP, where nothing waits on a person). Only fetch uses a model; everything else is plain code.

SkillWhat it does
capabilitiesWhich APIs and operations this agent may use, and the arguments each one takes: everything, the best matches for a few words, one API, or one operation in full with what its body holds. The answer stays small enough for an agent's context however many APIs there are.
executeRun one read operation, with optional field selection and pagination.
onboardTeach librarian an API: a spec URL, a docs URL, or just a base URL.
writeChange data, after a person approves it, a grant covers it, or an approver chose automatic approval for that operation. If nobody has enabled the operation yet, approvers are asked. The answer says how it ran: who approved, which grant, or automatic.
planSeveral writes on one API as one request: the approver sees all of them together and approves once, and they are made in order. A later step can use what an earlier one returned. The first that fails ends the plan and says what was made.
fetchPlain language ("open bugs assigned to the payments team"), planned by a model and executed by the policy engine.

Every result carries provenance: which API and operation, the URL with secrets redacted, when, for which agent and person, and which credential reference. The audit log is always on.

Documentation

  • Getting startedThe laptop walkthrough with Docker Compose.
  • With kagentFrom an empty cluster to an agent with no credentials whose write you approve, in about ten minutes.
  • Deploying for a teamKubernetes, step by step: the record repository, Slack, SSO, secrets, database, replicas.
  • IntegrationsLiteLLM, agentgateway, kagent and Agent Substrate, any A2A or MCP client, verified principals.
  • Registry formatWhat an entry holds, how approval works, and the record kept on GitHub.
  • Threat modelAssets, actors, threats and mitigations.
  • TroubleshootingWhat to check when agents, learning, Slack, sign-in or Kubernetes misbehave.

Roadmap

Done

  • Reads within policy, writes with approval or grants
  • Learning from specs, documentation and model knowledge, with change detection
  • Slack cards, Helm chart, a GitHub App that writes the record
  • MCP endpoint and the LiteLLM gateway
  • Verified principals from your identity provider
  • Replicas with shared state and no volumes, and one rate limit across them
  • Internal APIs learned on demand within the domains you list
  • A console for the people who run it: everything it knows, what waits on them, and the levers to revoke, block, re-learn and invalidate
  • Approve or deny a learned API from Slack: the review card leads to a signed-in page, and approving makes it verified at once
  • Acting as the person: APIs that need each person's own sign-in, with their own token and the API enforcing their access
  • Activity in the console: the last seven days in numbers, the busiest APIs, and recent events per API
  • Writes an agent wants but nobody has enabled yet become requests: Enable or Decline from Slack or the console, with a dedicated write credential asked for when there is none
  • Whole write flows enabled in one go, slashes in path arguments that are paths or refs, and plain-language requests that answer within a time budget
  • Automatic approval per operation with a daily cap and a one-click way back, and a Change control on every operation in the console
  • Grants that last as long as the approver chooses, re-timed, revoked or quieted from the console's Grants page
  • Idempotency keys kept with the write across replicas and restarts, every write answering how it ran, and rate limiting told apart from a permission problem
  • The database decides: approvals and every later decision take effect at once on every replica, and GitHub becomes the record, written after each decision and never read back
  • Agents on Agent Substrate and kagent with no key of their own: the platform's gateway signs each call, librarian verifies it and applies the rule for that agent
  • A key an API sends back in its answer is removed before any agent sees it, and a stored key that cannot be sent is refused without being named
  • Whatever an API does, the agent is told in words it can act on, no key leaves, and a write always ends; librarian doctor finds keys that earlier versions could have stored
  • Credentials made for each call instead of stored: OAuth client credentials, GitHub App tokens for one repository (read-only for a read), and AWS request signing
  • Limits inside an API: an agent held to some operations and to some values of their arguments, such as one organisation's repositories
  • Several writes approved as one plan: a commit and its pull request are one decision, shown to the approver whole
  • At home behind agentgateway and on kagent: tested as an MCP server and an A2A agent behind the gateway, a route on your Gateway from the chart, and an agent that can wait for a person's decision in the same turn
  • An answer too large to send comes back as its outline, agents are told which operations write, and nothing an agent wrote is read as markup in Slack
  • An Agent Skill that teaches agents librarian's tools, and an entry in the MCP Registry
  • Agents are told what each operation takes, and one that gets a name or an argument wrong is told the right one
  • The first answer fits in an agent's context: what an agent may use stays a few thousand tokens however many APIs there are, and says how to see the rest
  • Agents are told what a request body holds, read from the API's own description, so a write no longer starts with a guess
  • A body is sent the way the API takes it: as JSON, or as a form for APIs such as Stripe's, with the approver shown the fields as they are sent
  • Ten minutes on kagent and five behind agentgateway, as examples that run, with a recording of a real run; and tools that tell an agent what a body holds where it finds the operation, and what to do while a write waits

Next

  • Console actions that answer at once everywhere, with model guidance and Slack updates finishing in the background as the record already does
  • Verifying the SearXNG and Brave documentation search, and Google and Microsoft sign-in, live

Later

  • Vault, GCP Secret Manager and Azure Key Vault
  • Through kagent: the person behind an agent as well as the agent, and waking a suspended agent when its write is approved
  • A community registry of reviewed, signed entries