Skip to main content
Glama
Agent Capability Template

Agent Capability Template

by abhayraj-ai
README.md
# Agent Capability Template

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

Start an agent repo that plugs into [agent-hub](https://github.com/abhayraj-ai/agent-hub) as an MCP **capability**. It ships a working example (one tool, one skill, one eval) with auth, health, tests and CI already in place, so you only write your agent's tools.

## What you get

```
capability.json              the contract the hub registers: tools, side effects, skills, evals
skills/<name>/SKILL.md       how another agent should use your tools
evals/cases.json             checks the hub runs against your deployment
src/capability/server.ts     your tools  ← edit this
src/capability/kit.ts        shared runtime: MCP server, auth, skills, health (don't edit)
src/app/api/mcp/route.ts     POST /api/mcp, Streamable HTTP, stateless
src/app/api/health/route.ts  GET /api/health, reports configuration without values
scripts/capability.mjs       embeds skills, validates against the hub schema
```

## Use it

1. Click **Use this template**, clone your new repo and run `npm ci`.
2. In `capability.json`, set `id` (kebab-case, permanent), `name`, `description`, `repository` and `endpoints.production`.
3. Replace `analyze_text` in `src/capability/server.ts` with your tools, and keep `id`, `name` and `version` there equal to `capability.json`. For each tool:
   - validate input with zod and write a description another agent can act on;
   - declare it in `capability.json` with honest `sideEffects` (`contacts_people` and `spends_money` must set `requiresConfirmation: true`);
   - return `toolError("...")` for failures the user should hear about, and read keys with `requireEnv` so a missing key fails the call, not the build;
   - work over 60 seconds: return a job id (`mode: "async_job"`) and add a status tool.
4. Write `skills/<name>/SKILL.md` and at least one eval case per tool, then run `npm run capability:sync`.
5. Run the checks, deploy with `CAPABILITY_TRUSTED_CALLERS` (the hub's `team_id/project`) or `CAPABILITY_TOKENS` set, and [register it in the hub](https://github.com/abhayraj-ai/agent-hub/blob/main/docs/adding-a-capability.md).

```bash
npm run capability:check   # manifest and evals against the hub schema
npm test                   # contract (tools, skills, identity), evals and auth
npm run build
```

## Call it directly

Any MCP client can use a capability on its own:

```bash
curl -X POST https://<deployment>/api/mcp \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

## Rules the kit enforces

- `/api/mcp` returns 503 until a caller is configured and 401 for anyone else. Two ways in:
  - **Vercel OIDC (no shared secret):** list the hub's project in `CAPABILITY_TRUSTED_CALLERS` as `team_id/project-name`. The hub sends its Vercel-signed OIDC token; the kit verifies it against Vercel's public keys and accepts only production tokens from listed projects.
  - **Bearer tokens:** for other MCP clients, list tokens in `CAPABILITY_TOKENS`; they are compared in constant time.
- The server is stateless (no sessions), so it runs on serverless hosts; `GET` and `DELETE` return 405.
- Skills are embedded at build time and served as `skill://<id>/<name>` resources.
- `/api/health` says whether each required env var is set, never its value.

## License

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