Define once. Govern every call.
An embeddable microframework for application capabilities that agents and code can call.
📖 Documentation · Getting Started · Protocol Specification
Define a capability with a description, input and output schemas, and behavioral annotations. The protocol-neutral runtime applies identity, access control, approval, validation, middleware, execution, structured errors, and trace context when a call goes through apcore. Call the same capability directly from code or expose it through MCP, A2A, CLI, or HTTP adapters.
MCP tells an agent what it can call. apcore decides whether this call — with these arguments, by this identity — should run at all, and leaves evidence that it did.
This repository holds the protocol specification, JSON Schemas, cross-language conformance fixtures and three independently published runtime SDKs.
| Language | Install | Source |
|---|---|---|
| Python | pip install apcore |
Python SDK |
| TypeScript | npm install apcore-js |
TypeScript SDK |
| Rust | cargo add apcore |
Rust SDK |
Current versions are listed on the documentation home.
from apcore import APCore
client = APCore()
@client.module(id="math.add", description="Add two numbers")
def add(a: int, b: int) -> dict:
return {"sum": a + b}
print(client.call("math.add", {"a": 10, "b": 5})) # {'sum': 15}import { Type } from '@sinclair/typebox';
import { APCore } from 'apcore-js';
const client = new APCore();
const addition = client.module({
id: 'math.add',
description: 'Add two numbers',
inputSchema: Type.Object({ a: Type.Number(), b: Type.Number() }),
outputSchema: Type.Object({ sum: Type.Number() }),
execute: (inputs) => ({ sum: (inputs.a as number) + (inputs.b as number) }),
});
await addition.registration;
console.log(await client.call('math.add', { a: 10, b: 5 })); // { sum: 15 }use apcore::errors::ModuleError;
use apcore::{APCore, Context, Module};
use async_trait::async_trait;
use serde_json::{json, Value};
struct AddModule;
#[async_trait]
impl Module for AddModule {
fn description(&self) -> &str { "Add two numbers" }
fn input_schema(&self) -> Value {
json!({
"type": "object",
"properties": {"a": {"type": "integer"}, "b": {"type": "integer"}},
"required": ["a", "b"]
})
}
fn output_schema(&self) -> Value {
json!({"type": "object", "properties": {"sum": {"type": "integer"}}})
}
async fn execute(&self, inputs: Value, _ctx: &Context<Value>) -> Result<Value, ModuleError> {
let a = inputs["a"].as_i64().unwrap_or(0);
let b = inputs["b"].as_i64().unwrap_or(0);
Ok(json!({"sum": a + b}))
}
}
#[tokio::main]
async fn main() -> Result<(), ModuleError> {
let client = APCore::new();
client.register("math.add", Box::new(AddModule))?;
let result = client.call("math.add", json!({"a": 10, "b": 5}), None, None).await?;
println!("{result}"); // {"sum":15}
Ok(())
}The Getting Started guide continues with preflight validation, streaming, directory-based discovery, middleware and system modules.
ACL checks require an attached ACL and an active acl_check step. The default client attaches no ACL when the ACL file is absent. The active approval gate fails closed by default: it rejects an approval-required call with APPROVAL_DENIED when no ApprovalHandler is configured, and requires approval for destructive modules unless an explicit ExecutionPolicy disables strict or gate_destructive. See the security setup guide.
| Concern | Mechanism | Reference |
|---|---|---|
| Contract | Every module declares description, input_schema and output_schema (JSON Schema Draft 2020-12). The standard pipeline validates inputs and module output. |
Schema System |
| Behavior | Annotations such as readonly, destructive, idempotent, requires_approval, open_world, streaming, cacheable, paginated |
Module Interface |
| Access | Pattern-based ACL rules evaluated first-match-wins, with identity, role and call-depth conditions; default_effect: deny |
ACL System |
| Approval | A human-in-the-loop gate for modules that require approval, through a pluggable ApprovalHandler |
Approval System |
| Safety | Call-depth limits and circular-call detection across nested calls | Call Chain Guard |
| Extension | Onion-model middleware and a configurable step pipeline | Middleware · Execution Pipeline |
| Evidence | W3C trace context, tracing, metrics, usage, redaction of x-sensitive fields, events and audit |
Observability |
| Recovery | Structured errors with retryable, ai_guidance, user_fixable and suggestion |
Error System |
The standard call uses this eleven-step pipeline:
1. context_creation trace_id, caller_id, call_chain, identity
2. call_chain_guard depth limit and circular-call detection
3. module_lookup resolve the module in the registry
4. acl_check caller → target permission
5. approval_gate human approval when required
6. middleware_before before() hooks, in order
7. input_validation validate inputs against input_schema
8. execute module.execute() (or stream())
9. output_validation validate output against output_schema
10. middleware_after after() hooks, in reverse order
11. return_result
on error: on_error() hooks in reverse order
Module IDs derive from the file path under the extensions root — extensions/executor/email/send_email.py becomes executor.email.send_email — so the same directory layout yields the same IDs in every language.
Adapters are independently versioned and available for Python, TypeScript and Rust under the same package name.
| Adapter | Projects modules as | Repository |
|---|---|---|
apcore-mcp |
MCP tools (with a Tool Explorer UI) | apcore-mcp |
apcore-a2a |
A2A skills and Agent Card metadata | apcore-a2a |
apcore-cli |
CLI commands and arguments | apcore-cli |
apcore-toolkit |
Shared scanners, schema extraction and output writers for adapter authors | apcore-toolkit |
Framework integrations bind HTTP endpoints to modules: fastapi-apcore, django-apcore, flask-apcore, nestjs-apcore, express-apcore, hono-apcore, axum-apcore. To write your own, see the Adapter Development guide.
Use a protocol SDK directly when a single protocol server is all you need. Use apcore when validation, access, approval and audit rules must stay the same across more than one caller or surface — see Positioning.
| Start here | Build | Reference |
|---|---|---|
| Getting Started | Guides — creating modules, schemas, ACL, middleware, testing, cookbooks | Feature reference — one page per subsystem |
| Core Concepts | Troubleshooting | Specification — normative protocol, conformance, type mapping |
| Architecture | Multi-language development | Decision register — why the spec says what it says |
| Glossary | CHANGELOG |
Project documents: Scope · Roadmap · Adopters · Governance · Maintainers · Security · Code of Conduct
Questions and ideas go to GitHub Discussions. Specification feedback, new SDKs, adapters and documentation fixes are welcome — read CONTRIBUTING.md first. Never report a vulnerability in a public issue; follow SECURITY.md.
Apache 2.0