@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
44 lines • 2.31 kB
TypeScript
import type { ApplicationService } from '@adonisjs/core/types';
import type { DevToolsHub } from '../src/dev-tools/contract.js';
declare module '@adonisjs/core/types' {
interface ContainerBindings {
/** The dev tools hub every `@adonis-agora` lib registers its developer tools into. */
'agora.devTools': DevToolsHub;
}
}
/**
* Wires the agent's {@link ToolRegistry} to the outside world over the Model Context Protocol
* (Streamable HTTP). Reads `config/mcp.ts` and mounts:
*
* - `POST|GET|DELETE {path}` — the MCP endpoint (initialize/session resume, SSE stream, close).
* - `GET /.well-known/oauth-protected-resource{path}` — RFC 9728 protected-resource metadata, mounted
* only when `auth.oauth` is set, so MCP clients can discover how to authenticate.
*
* …once for the top-level config and once per entry of `endpoints`: each is a protected resource of
* its own, with its registry, auth, sessions and metadata.
*
* A refused request answers `401` (or `403` for an {@link McpAuthError} with that status) with a
* `WWW-Authenticate: Bearer …` challenge; with OAuth it carries `resource_metadata`, which is what makes
* an MCP client discover the authorization server and open the login. URLs are built from
* `config.publicUrl` when set, else from the request's protocol and `Host`.
*
* Every request is authenticated: the bearer token is verified via `config.auth` (e.g. `authKitAuth()`),
* the resolved actor attached to the transport's `AuthInfo`, and `tools/list` / `tools/call` run against
* the SAME `ToolRegistry` singleton the agent loop uses — so a role-checked tool stays role-checked, and
* a fail-closed gate stays fail-closed, no matter the surface.
*/
export default class McpProvider {
#private;
protected app: ApplicationService;
constructor(app: ApplicationService);
/**
* Bind the dev tools hub (`'agora.devTools'`). Every provider's `register()` runs before any
* `boot()`, so a lib finds it from its own `boot()` whatever the order in `adonisrc.ts`.
*/
register(): void;
boot(): Promise<void>;
/** Say once, when the app is up, which libs serve dev tools (every lib has booted by now). */
ready(): Promise<void>;
shutdown(): Promise<void>;
}
//# sourceMappingURL=mcp_provider.d.ts.map