Skip to main content
Glama
README.md
# Agent Hub and Agent Studio

[![CI](https://github.com/abhayraj-ai/agent-hub/actions/workflows/ci.yml/badge.svg)](https://github.com/abhayraj-ai/agent-hub/actions/workflows/ci.yml) [![License: PolyForm Noncommercial](https://img.shields.io/badge/license-PolyForm%20Noncommercial-blue.svg)](LICENSE)

One MCP endpoint in front of many independently built agents. Every agent repo that follows the [capability template](https://github.com/abhayraj-ai/agent-capability-template) becomes a **capability**: the hub registers it, namespaces its tools, and adds auth, rate limits, approvals and health checks. Adding a new agent takes one pull request here and no change to the hub's code.

```mermaid
flowchart LR
    C["MCP client<br/>(orchestrator, Claude, Cursor)"] -->|"Bearer token"| G
    subgraph Hub["agent-hub"]
      G["MCP gateway<br/>/api/mcp"] --- R[("Registry<br/>capabilities/*.json")]
    end
    G -->|"web_research__*"| W["Web Research Agent<br/>ai-web-research-assistant"]
    G -->|"trip_planner__*"| T["Trip Planner Agent<br/>ai-trip-planner-agent"]
    G -.->|"next PR"| N["Next capability"]
```

## Agent Studio

The hub's web app is **Agent Studio**, the place to see and use every connected agent:

- **Capabilities:** every agent with a live status light and its tools; each agent's page shows its skill and a form, built from the tool's own input schema, to run any tool.
- **Chat:** an orchestrator that picks capabilities, reads their skills and chains their tools for one request, showing each call. Tools that contact people or spend money stop and wait for the owner's approval in the conversation.
- **Access:** anyone can browse; running tools and the chat need the owner, who signs in once with a hub token (the cookie holds a signed session, never the token).
- **Cost:** the chat uses a low-cost model on Vercel AI Gateway with at most 8 steps and 1,500 output tokens a reply, 30 messages a chat and a daily request cap; the gateway team budget is the hard ceiling.

## Why

Each agent repo works on its own: its own deploy, keys and data. Without a hub, every client has to know every agent's URL, auth and quirks, and every new agent means changing the clients. The hub turns that N×M wiring into one contract:

- **A capability owns its code and secrets.** The hub never holds an OpenAI, Tavily or Twilio key, only one scoped bearer token per capability.
- **The manifest is the contract.** `capability.json` declares the tools, what each one can do to the world (`sideEffects`), its timeout and its skills. The hub exposes only declared tools, even if a capability serves more.
- **Risky actions need a human.** Tools that contact people or spend money must declare `requiresConfirmation`; the hub then returns a signed, argument-bound token that the client may only pass back after the user approves.
- **Skills travel with the code.** Each capability publishes `SKILL.md` files as MCP resources, so the orchestrator learns how to use a tool from the repo that owns it.

## How a call flows

1. The client connects to `/api/mcp` with its hub token and lists tools. The hub fetches each capability's live tool list (cached for a minute), keeps the declared ones and prefixes them: `trip-planner` + `plan_trip` → `trip_planner__plan_trip`.
2. The client calls `hub__list_capabilities` to choose, and `hub__read_skill` to learn the capability's rules.
3. The client calls a tool. The hub checks the argument size (32 KB) and the capability's rate limit, asks for confirmation if the tool needs it, then forwards the call with the capability's token and its declared timeout.
4. The answer comes back capped at 100,000 characters. Each call logs one JSON line with the capability, tool, outcome and duration, never the arguments.

If a capability is down, its tools drop out of the list and calls to it fail cleanly; the rest of the hub keeps working.

## Capabilities

| Capability | Repo | Tools |
|---|---|---|
| Web Research Agent | [ai-web-research-assistant](https://github.com/abhayraj-ai/ai-web-research-assistant) | `search_web`, `research_topic` |
| Trip Planner Agent | [ai-trip-planner-agent](https://github.com/abhayraj-ai/ai-trip-planner-agent) | `plan_trip`, `get_trip`, `refine_trip` |

The live list, with each tool's side effects, is on the hub's home page; `/api/health` reports whether each capability is up.

## Connect a client

```json
{
  "mcpServers": {
    "agent-hub": {
      "type": "http",
      "url": "https://<your-hub-deployment>/api/mcp",
      "headers": { "Authorization": "Bearer <hub token>" }
    }
  }
}
```

## Add a capability

1. Create the agent repo from [agent-capability-template](https://github.com/abhayraj-ai/agent-capability-template), or copy its `src/capability/kit.ts` and `scripts/capability.mjs` into an existing repo.
2. Fill in `capability.json`, the tools, a `SKILL.md` and eval cases; deploy it with `CAPABILITY_TOKENS` set.
3. Check the deployment: `CAPABILITY_TOKEN_<ID>=... npm run capability:check -- ./path/to/capability.json --url https://...`
4. Open a PR here adding `capabilities/<id>.json`, run `npm run registry:generate`, and add `CAPABILITY_TOKEN_<ID>` to the hub's environment.

The full checklist is in [docs/adding-a-capability.md](docs/adding-a-capability.md); design decisions are in [docs/architecture.md](docs/architecture.md).

## Run locally

```bash
npm ci
cp .env.example .env.local   # set HUB_API_TOKENS, HUB_CONFIRMATION_SECRET and capability tokens
npm run dev                  # http://localhost:3000, MCP at /api/mcp
```

To develop against local capabilities, point the hub at them:

```bash
HUB_ENDPOINT_OVERRIDES=trip-planner=http://127.0.0.1:3001,web-research=http://127.0.0.1:3002 npm run dev
```

| Command | What it does |
|---|---|
| `npm test` | Gateway, confirmation, rate-limit, auth and end-to-end MCP tests |
| `npm run registry:check` | Validates every manifest and checks the generated registry is current |
| `npm run schema:check` | Checks `schema/*.json` matches the zod source of truth |
| `npm run capability:check -- <id>` | Checks a deployed capability: tools, skills and live evals |

## Deploy

Deploy to Vercel and set one secret, `HUB_API_TOKENS` (see [`.env.example`](.env.example)). Everything else is keyless:

- **Hub → capabilities:** the hub presents its Vercel OIDC token; each capability lists the hub's `team_id/project` in `CAPABILITY_TRUSTED_CALLERS` and verifies the token against Vercel's public keys.
- **Chat model:** Vercel AI Gateway authenticates with the same OIDC token.
- **Confirmation tokens:** signed with a key derived from the hub token unless `HUB_CONFIRMATION_SECRET` is set.

Until `HUB_API_TOKENS` is set, the studio can be browsed but `/api/mcp`, running tools and the chat are refused.

## Roadmap

- [x] **Phase 1, foundation:** manifest schema, capability template, registry and gateway; Web Research and Trip Planner connected.
- [x] **Phase 2, orchestrator:** Agent Studio with a capability console and a chat orchestrator that chains tools across capabilities.
- [ ] **Phase 3, hard cases:** the Calling Agent (async jobs and confirmation) and the RAG support agent.
- [ ] **Phase 4, scale-out:** the remaining agent repos on the template, scheduled evals and a capabilities dashboard.

## Security

See [SECURITY.md](SECURITY.md). In short: tokens are compared in constant time, every endpoint fails closed when unconfigured, capability results are data the client must not treat as instructions, and nothing secret is logged.

## License

[PolyForm Noncommercial 1.0.0](LICENSE). Copyright (c) 2026 Abhay Raj Singh.