Skip to content

AI agent integration (MCP)

The Aster CLI bridge turns published service methods into tools for an MCP host. Use it to let an assistant query a worker’s catalog without writing a separate tool adapter. The bridge discovers payload schemas and forwards calls; the producer must still authorize each method.

Start the Python first service and install a CLI exposing aster mcp as described in the CLI reference. Keep the producer online and use its real address. CLI and SDK packaging have separate compatibility requirements. This integration has not received a clean-host MCP-host walkthrough.

The bridge derives tool schemas from the published service contract.

Terminal window
# Terminal 1: run your service
python producer.py
# Terminal 2: expose it to AI agents via MCP
aster mcp <endpoint-addr>

Configure your MCP client to launch this command over stdio, as shown below.

Diagram source
graph TD
    A["Claude / AI Agent"] -->|"stdio (JSON-RPC 2.0)"| B["aster mcp (MCP server)"]
    B -->|"Aster RPC (QUIC)"| C["Your Service (P2P via Iroh)"]
  1. aster mcp connects to the producer and runs the admission handshake
  2. It reads contract manifests from the registry to discover method schemas
  3. Each method becomes an MCP tool with a JSON Schema derived from the request type fields
  4. Tool calls are forwarded as Aster RPC calls; results returned as JSON

The MCP server uses dynamic type synthesis to invoke supported methods. Contract manifests include Fory wire tags for every field, so the server can build correctly serialized typed requests directly from the agent’s JSON arguments. No local Python type definitions or generated stubs are needed.

The agent sees tools like:

HelloService.say_hello
- name (string, required)
FileStore.get (unary)
FileStore.list (server_stream schema; runtime qualification required)
FileStore.upload (client_stream, accepts aster_items array)

The bridge uses Aster credentials and local exposure controls. Configure both for the methods the agent needs.

The MCP server is just another consumer. Give it a restricted credential:

Terminal window
# Mint a credential specifically for AI agent use
aster trust sign --root-key root.key --type policy \
--attributes '{"aster.role": "ai-reader"}' --out ai-agent.token
# MCP server uses the AI's credential, not yours
aster mcp <peer> --rcan ai-agent.token

On the producer, declare which methods the AI role can access:

from aster import service, rpc, any_of
# Definition fragment: supply these application payload classes.
@service(name="DataService")
class DataService:
@rpc(requires=any_of("reader", "ai-reader")) # AI can read
async def get_record(self, req: RecordRequest) -> RecordResponse: ...
@rpc(requires="admin") # AI cannot call this
async def delete_record(self, req: RecordRequest) -> DeleteResult: ...

The producer should allow the read and deny deletion for the restricted principal. Do not assume a denied method is absent from discovered manifests or the MCP tool list. Use local allow/deny patterns to control tool visibility, and test producer denial independently. The decorator block is a policy sketch; provide RecordRequest, RecordResponse, DeleteResult, and handler bodies before registering it.

Local glob patterns as a safety net, even if the credential allows more:

Terminal window
# Only expose read methods
aster mcp <peer> --allow "DataService.get_*" --deny "*.delete_*"
# Only specific services
aster mcp <peer> --allow "HelloService.*" --allow "StatusService.*"

Do not rely on the CLI’s --confirm prompt when an MCP host launches the bridge over stdio. The prompt reads the same stdin stream as the MCP JSON-RPC reader, so approval input can conflict with protocol traffic. Use credential restrictions and allow/deny filters, and configure any operator approval in the MCP host itself.

Aster Pattern MCP Behavior
unary Direct request/response (1:1 mapping)
server_stream Schema advertises collection controls aster_max_items and aster_timeout; runtime collection needs qualification before use
client_stream Pass items via aster_items array parameter
bidi_stream Not exposed as tools

Example: calling a server-streaming method:

{
"name": "Analytics.watchMetrics",
"arguments": {
"interval": 5,
"aster_max_items": 10,
"aster_timeout": 15
}
}

These are the advertised schema controls. Source review found a problem in the bridge’s asynchronous server-stream collection path; do not depend on this path without testing the installed CLI. Prefer a bounded unary query for assistant tools until that integration is qualified.

Use your host’s documented stdio-server configuration location. The following is a common mcpServers configuration shape, not a verified settings path for every host. Use an absolute executable path if the host does not inherit your shell PATH:

{
"mcpServers": {
"my-service": {
"command": "aster",
"args": ["mcp", "<endpoint-addr>"],
"env": {}
}
}
}

With credentials:

{
"mcpServers": {
"my-service": {
"command": "aster",
"args": ["mcp", "<endpoint-addr>", "--rcan", "ai-agent.token", "--deny", "*.delete_*"]
}
}
}
aster mcp <address> [options]
Arguments:
address Peer address (aster1... ticket)
Options:
--rcan PATH Enrollment credential for the AI agent
--allow PATTERN Glob for allowed tools (repeatable)
--deny PATTERN Glob for denied tools (repeatable)

Start with an allow pattern for the greeting method alone. Ask the host to list tools, invoke the greeting with name set to World, and expect Hello, World!. Confirm methods outside the allow pattern are absent. Then test an otherwise visible but unauthorized method with a restricted credential and confirm producer rejection.

If no tools appear, check admission, manifest arrival, and local filters separately. If a tool is listed but fails, inspect payload compatibility and method authorization. Launch credentials and token paths belong to the bridge process; avoid unintentionally inheriting an operator credential from the host environment.