agentleFS
MicrosoftKnown publishermicrosoft/agent-host-protocol/plugins/copilot-plugin/skills/ahp-client/SKILL.md

ahp-client

Skill444 starsChanged 50 days agoMITView on GitHub

Interact with an Agent Host Protocol (AHP) server via WebSocket. Use when asked to connect to, message, or control an AHP server.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    After subscribing, subsequent mutations arrive as action notifications.

    line 83
  2. Distinctive:

    If the agent calls a tool, the server sends:

    line 127
  3. Very specific:

    If the connection drops, call connect again and send a reconnect message instead of initialize:

    line 167
  4. Distinctive:

    Read these files when you need exact field names, type shapes, or edge-case behaviour.

    line 229

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Agent Host Protocol – Copilot Skill

You have access to an MCP server (ahp-websocket) that lets you connect to an Agent Host Protocol server over WebSocket and exchange JSON-RPC 2.0 messages.

Available MCP tools

ToolPurpose
connectOpen (or re-open) a WebSocket to an AHP server URL
sendSend a JSON-RPC message and get the response + any pending notifications
get_notificationsDrain the notification inbox (optionally wait N seconds first)
statusCheck connection state, pending request count, inbox depth
next_idGet a unique incrementing integer for JSON-RPC request id fields

Quick-start workflow

1. connect(url: "ws://localhost:3000")
2. send initialize notification
3. wait for serverHello via get_notifications
4. subscribe to root state
5. create a session, subscribe, send turns

Protocol overview

AHP is a Redux-inspired state synchronisation protocol built on JSON-RPC 2.0 over WebSocket. The server maintains an authoritative state tree; clients apply actions optimistically and reconcile with the server's echoed actions.

Key concepts:

  • Root state (ahp-root://) – lists available agents/models.
  • Session state (ahp-session:/<uuid>) – per-conversation state with turns, deltas, tool calls, and permissions.
  • Actions – the sole mutation mechanism, wrapped in ActionEnvelopes with a serverSeq.
  • Subscriptions – clients subscribe to URI-identified state resources to receive action streams.
  • Notifications – ephemeral broadcasts (session added/removed) that are NOT part of the state tree and NOT replayed on reconnect.

Connection lifecycle

1. Initialize

Send an initialize notification (no id field):

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "protocolVersions": ["0.3.0"],
    "clientId": "<unique-client-id>",
    "initialSubscriptions": ["ahp-root://"]
  }
}

Then call get_notifications(wait: 2) to collect the serverHello response, which includes snapshots for any initial subscriptions.

2. Subscribe to state

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "subscribe",
  "params": { "channel": "ahp-root://" }
}

The response contains the current state snapshot. After subscribing, subsequent mutations arrive as action notifications.

3. Create a session

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "createSession",
  "params": {
    "session": "<provider>:/<uuid>",
    "provider": "<provider>",
    "model": "<model-id>"
  }
}

Then subscribe to the session URI. Wait for a session/ready action.

4. Send a message (start a turn)

Dispatch a session/turnStarted action as a notification (fire-and-forget):

{
  "jsonrpc": "2.0",
  "method": "dispatchAction",
  "params": {
    "channel": "<provider>:/<uuid>",
    "clientSeq": 1,
    "action": {
      "type": "session/turnStarted",
      "turnId": "<unique-turn-id>",
      "userMessage": { "text": "Hello, world!" }
    }
  }
}

Then poll get_notifications(wait: 2) to collect streaming session/delta actions until you see session/turnComplete.

5. Handle tool calls and permissions

If the agent calls a tool, the server sends:

  • session/toolStart – tool invocation started
  • session/permissionRequest – user approval needed

Resolve permissions with:

{
  "jsonrpc": "2.0",
  "method": "dispatchAction",
  "params": {
    "channel": "<provider>:/<uuid>",
    "clientSeq": 2,
    "action": {
      "type": "session/permissionResolved",
      "turnId": "<turn-id>",
      "requestId": "<perm-request-id>",
      "approved": true
    }
  }
}

6. Other commands

CommandPurpose
listSessionsList all session summaries
disposeSessionTear down a session
resourceReadRead content by URI reference
resourceListList directory entries
resourceCopyCopy a resource
resourceDeleteDelete a resource
resourceMoveMove/rename a resource
resourceWriteWrite content to a file
fetchTurnsFetch historical turns for a session

7. Reconnection

If the connection drops, call connect again and send a reconnect message instead of initialize:

{
  "jsonrpc": "2.0",
  "method": "reconnect",
  "params": {
    "clientId": "<same-client-id>",
    "lastSeenServerSeq": 42,
    "subscriptions": ["ahp-root://", "<provider>:/<uuid>"]
  }
}

Action types reference

Client-dispatchable actions

ActionEffect
session/turnStartedBegin a new turn with a user message
session/permissionResolvedApprove or deny a pending tool permission
session/turnCancelledAbort an in-progress turn
session/modelChangedSwitch the model for future turns

Server-originated actions

ActionMeaning
root/agentsChangedAvailable agents or models changed
session/readySession backend initialized
session/creationFailedSession failed to initialize
session/deltaStreaming text content for a turn
session/toolStartAgent is calling a tool
session/toolDeltaStreaming tool output
session/toolCompleteTool execution finished
session/permissionRequestUser approval needed for a tool
session/turnCompleteTurn finished
session/errorError during turn

Full documentation

For complete protocol details, refer to the docs in this repository:

  • Guide: docs/guide/ – conceptual overviews and walkthroughs
    • getting-started.md – end-to-end example
    • state-model.md – full state tree shape
    • actions.md – how actions work
    • reconciliation.md – write-ahead reconciliation algorithm
  • Specification: docs/specification/ – normative protocol spec
    • transport.md – transport requirements
    • lifecycle.md – connection, session, and reconnection lifecycle
    • subscriptions.md – subscription mechanics
    • versioning.md – version negotiation
  • Reference: docs/reference/ – complete type references
    • messages.md – all state types
    • actions.md – all action types with fields
    • commands.md – all JSON-RPC commands
    • notifications.md – all notification types
    • error-codes.md – error code reference

Read these files when you need exact field names, type shapes, or edge-case behaviour.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.