Skip to content

Commands

Commands are JSON-RPC requests from the client to the server. They return a result or a JSON-RPC error.

JSON Schema: commands.schema.json

initialize 📄

Establishes a new connection and negotiates the protocol version. This MUST be the first message sent by the client.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
protocolVersionsstring[]YesProtocol versions the client is willing to speak, ordered from most
preferred to least preferred. Each entry is a SemVer
MAJOR.MINOR.PATCH string (e.g. "0.1.0").

The server selects one entry and returns it as InitializeResult.protocolVersion. If the server cannot speak any of the offered versions, it MUST return error code -32005 (UnsupportedProtocolVersion). | | clientId | string | Yes | Unique client identifier | | initialSubscriptions | URI[] | No | URIs to subscribe to during handshake | | locale | string | No | IETF BCP 47 language tag indicating the client's preferred locale (e.g. "en-US", "ja"). The server SHOULD use this to localise user-facing strings such as confirmation option labels. |

Result:

FieldTypeRequiredDescription
protocolVersionstringYesProtocol version selected by the server. MUST be one of the entries in
InitializeParams.protocolVersions. Formatted as a SemVer
MAJOR.MINOR.PATCH string (e.g. "0.1.0").
serverSeqnumberYesCurrent server sequence number
snapshotsSnapshot[]YesSnapshots for each initialSubscriptions URI
defaultDirectoryURINoSuggested default directory for remote filesystem browsing
completionTriggerCharactersstring[]NoCharacters that, when typed in a {@link UserMessage} input, SHOULD cause
the client to issue a completions request with
{@link CompletionItemKind.UserMessage}. Typically includes characters like
'@' or '/'.

See Lifecycle for details.


reconnect 📄

Re-establishes a dropped connection. The server replays missed actions or provides fresh snapshots.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeDescription
clientIdstringClient identifier from the original connection
lastSeenServerSeqnumberLast serverSeq the client received
subscriptionsURI[]URIs the client was subscribed to

Result (replay): When the server can replay from the requested sequence:

FieldTypeDescription
typeReconnectResultType.ReplayDiscriminant
actionsActionEnvelope[]Missed action envelopes since lastSeenServerSeq
missingURI[]URIs from ReconnectParams.subscriptions that the server cannot resume.
This includes resources that no longer exist (e.g. disposed sessions or
terminals) as well as resources the client is no longer permitted to
observe. Clients SHOULD drop these from their local subscription set.

Result (snapshot): When the gap exceeds the replay buffer:

FieldTypeDescription
typeReconnectResultType.SnapshotDiscriminant
snapshotsSnapshot[]Fresh snapshots for each subscription

Reconnect result when the server can replay from the requested sequence.

The server MUST include all replayed data in the response.

See Lifecycle for details.


createSession 📄

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
sessionURIYesSession URI (client-chosen, e.g. copilot:/<uuid>)
providerstringNoAgent provider ID
modelModelSelectionNoModel selection (ID and optional model-specific configuration)
workingDirectoryURINoWorking directory for the session
forkSessionForkSourceNoFork from an existing session. The new session is populated with content
from the source session up to and including the specified turn's response.
configRecord<string, unknown>NoAgent-specific configuration values collected via resolveSessionConfig.
Keys and values correspond to the schema returned by the server.
activeClientSessionActiveClientNoEagerly claim the active client role for the new session.

When provided, the server initializes the session with this client as the active client, equivalent to dispatching a session/activeClientChanged action immediately after creation. The clientId MUST match the clientId the creating client supplied in initialize. |

Result: null on success.


disposeSession 📄

Disposes a session and cleans up server-side resources.

The server broadcasts a notify/sessionRemoved notification to all clients.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeDescription
sessionURISession URI to dispose

Result: null on success.

The server broadcasts a notify/sessionRemoved notification to all clients.


listSessions 📄

Returns a list of session summaries. Used to populate session lists and sidebars.

The session list is not part of the state tree because it can be arbitrarily large. Clients fetch it imperatively and maintain a local cache updated by notify/sessionAdded and notify/sessionRemoved notifications.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
filterobjectNoOptional filter criteria

Result:

FieldTypeDescription
itemsSessionSummary[]The list of session summaries.

The session list is not part of the state tree because it can be arbitrarily large. Clients fetch it imperatively and maintain a local cache updated by notify/sessionAdded and notify/sessionRemoved notifications.


resourceRead 📄

Reads the content of a resource by URI.

Content references keep the state tree small by storing large data (images, long tool outputs) by reference rather than inline.

Binary content (images, etc.) MUST use base64 encoding. Text content MAY use utf-8 encoding.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
uristringYesContent URI from a ContentRef
encodingContentEncodingNoPreferred encoding for the returned data (default: server-chosen)

Result:

FieldTypeRequiredDescription
datastringYesContent encoded as a string
encodingContentEncodingYesHow data is encoded
contentTypestringNoContent type (e.g. "image/png", "text/plain")

Example:

jsonc
// Client → Server
{ "jsonrpc": "2.0", "id": 10, "method": "resourceRead",
  "params": { "uri": "copilot:/<uuid>/content/img-1" } }

// Server → Client
{ "jsonrpc": "2.0", "id": 10, "result": {
  "data": "iVBORw0KGgo...",
  "encoding": "base64",
  "contentType": "image/png"
}}

Content references keep the state tree small by storing large data (images, long tool outputs) by reference rather than inline.

Binary content (images, etc.) MUST use base64 encoding. Text content MAY use utf-8 encoding.


resourceWrite 📄

Writes content to a file on the server's filesystem.

Binary content (images, etc.) MUST use base64 encoding. Text content MAY use utf-8 encoding.

If the file does not exist, it is created. If the file already exists, it is overwritten unless createOnly is set.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
uriURIYesTarget file URI on the server filesystem
datastringYesContent encoded as a string
encodingContentEncodingYesHow data is encoded
contentTypestringNoContent type (e.g. "text/plain", "image/png")
createOnlybooleanNoIf true, the server MUST fail if the file already exists instead of
overwriting it. Useful for safe creation of new files.

Result:

FieldTypeDescription

Example:

jsonc
// Client → Server
{ "jsonrpc": "2.0", "id": 11, "method": "resourceWrite",
  "params": { "uri": "file:///workspace/hello.txt", "data": "SGVsbG8=",
             "encoding": "base64", "contentType": "text/plain" } }

// Server → Client
{ "jsonrpc": "2.0", "id": 11, "result": {} }

Binary content (images, etc.) MUST use base64 encoding. Text content MAY use utf-8 encoding.

If the file does not exist, it is created. If the file already exists, it is overwritten unless createOnly is set.


resourceList 📄

Lists directory entries at a file URI on the server's filesystem.

This is intended for remote folder pickers and similar UI that needs to let users navigate the server's local filesystem.

The server MUST return success only if the target exists and is a directory. If the target does not exist, is not a directory, or cannot be accessed, the server MUST return a JSON-RPC error.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeDescription
uriURIDirectory URI on the server filesystem

Result:

FieldTypeDescription
entriesDirectoryEntry[]Entries directly contained in the requested directory

This is intended for remote folder pickers and similar UI that needs to let users navigate the server's local filesystem.

The server MUST return success only if the target exists and is a directory. If the target does not exist, is not a directory, or cannot be accessed, the server MUST return a JSON-RPC error.


resourceCopy 📄

Copies a resource from one URI to another on the server's filesystem.

If the destination already exists, it is overwritten unless failIfExists is set.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
sourceURIYesSource URI to copy from
destinationURIYesDestination URI to copy to
failIfExistsbooleanNoIf true, the server MUST fail if the destination already exists instead
of overwriting it.

Result:

FieldTypeDescription

If the destination already exists, it is overwritten unless failIfExists is set.


resourceDelete 📄

Deletes a resource at a URI on the server's filesystem.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
uriURIYesURI of the resource to delete
recursivebooleanNoIf true and the target is a directory, delete it and all its contents
recursively. If false (default), deleting a non-empty directory MUST fail.

Result:

FieldTypeDescription

resourceMove 📄

Moves (renames) a resource from one URI to another on the server's filesystem.

If the destination already exists, it is overwritten unless failIfExists is set.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
sourceURIYesSource URI to move from
destinationURIYesDestination URI to move to
failIfExistsbooleanNoIf true, the server MUST fail if the destination already exists instead
of overwriting it.

Result:

FieldTypeDescription

If the destination already exists, it is overwritten unless failIfExists is set.


resourceRequest 📄

Requests permission to access a resource on the receiver's filesystem.

resourceRequest is symmetrical and MAY be sent in either direction: a client asks the server to grant access to a server-side resource, or a server asks the client to grant access to a client-side resource. The receiver decides whether to allow, deny, or prompt the user for the requested access.

If the receiver denies access, it MUST respond with PermissionDenied (-32009). The error data MAY include a ResourceRequestParams value describing the access the caller would need to be granted for the operation to succeed; see PermissionDeniedErrorData in types/errors.ts.

After a successful resourceRequest, the caller MAY use the corresponding resource* commands (e.g. resourceRead, resourceWrite) to perform the operation. Receivers MAY rescind access at any time by returning PermissionDenied on subsequent operations.

Either read, write, or both SHOULD be set to true. A request with neither flag set is treated as read: true by receivers.

PropertyValue
DirectionClient ↔ Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
uriURIYesResource URI being requested. Typically a file: URI on the receiver's
filesystem, but any URI scheme that the receiver mediates access to is
allowed.
readbooleanNoWhether the caller needs read access to the resource.
writebooleanNoWhether the caller needs write access to the resource.

Result:

FieldTypeDescription

resourceRequest is symmetrical and MAY be sent in either direction: a client asks the server to grant access to a server-side resource, or a server asks the client to grant access to a client-side resource. The receiver decides whether to allow, deny, or prompt the user for the requested access.

If the receiver denies access, it MUST respond with PermissionDenied (-32009). The error data MAY include a ResourceRequestParams value describing the access the caller would need to be granted for the operation to succeed; see PermissionDeniedErrorData in types/errors.ts.

After a successful resourceRequest, the caller MAY use the corresponding resource* commands (e.g. resourceRead, resourceWrite) to perform the operation. Receivers MAY rescind access at any time by returning PermissionDenied on subsequent operations.

Either read, write, or both SHOULD be set to true. A request with neither flag set is treated as read: true by receivers.


fetchTurns 📄

Fetches historical turns for a session. Used for lazy loading of conversation history.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeRequiredDescription
sessionURIYesSession URI
beforestringNoTurn ID to fetch before (exclusive). Omit to fetch from the most recent turn.
limitnumberNoMaximum number of turns to return. Server MAY impose its own upper bound.

Result:

FieldTypeDescription
turnsTurn[]The requested turns, ordered oldest-first
hasMorebooleanWhether more turns exist before the returned range

Example:

jsonc
// Client → Server (fetch the 20 most recent turns)
{ "jsonrpc": "2.0", "id": 8, "method": "fetchTurns",
  "params": { "session": "copilot:/<uuid>", "limit": 20 } }

// Server → Client
{ "jsonrpc": "2.0", "id": 8, "result": {
  "turns": [ { "id": "t1", ... }, { "id": "t2", ... } ],
  "hasMore": true
}}

// Client → Server (fetch 20 turns before t1)
{ "jsonrpc": "2.0", "id": 9, "method": "fetchTurns",
  "params": { "session": "copilot:/<uuid>", "before": "t1", "limit": 20 } }

completions 📄

Requests completion items for a partially-typed input (e.g. a user message the user is currently composing). Used to power @-mention pickers, file/symbol references, and similar inline-completion experiences.

Servers SHOULD treat this command as best-effort and return promptly. The client SHOULD debounce calls to avoid flooding the server with requests on every keystroke.

PropertyValue
DirectionClient → Server
TypeRequest

Parameters:

FieldTypeDescription
kindCompletionItemKindWhat kind of completion is being requested.
sessionURIThe session URI the completion is being requested for.
textstringThe complete text of the input being completed (e.g. the full user
message text typed so far).
offsetnumberThe character offset within text at which the completion is requested,
measured in UTF-16 code units. MUST satisfy 0 &lt;= offset &lt;= text.length.

Result:

FieldTypeDescription
itemsCompletionItem[]The completion items, in the order the server suggests displaying them.

Example:

jsonc
// User has typed "look at

Servers SHOULD treat this command as best-effort and return promptly. The
client SHOULD debounce calls to avoid flooding the server with requests on
every keystroke.

---

## Client-Dispatched Actions

In addition to commands, clients interact with the server by **dispatching actions** as fire-and-forget notifications:

```jsonc
// Client → Server
{
  "jsonrpc": "2.0",
  "method": "dispatchAction",
  "params": {
    "clientSeq": 1,
    "action": { "type": "session/turnStarted", "session": "copilot:/<uuid>", ... }
  }
}

These are write-ahead: the client applies them optimistically to local state. See Actions for the full list of client-dispatchable actions.

ActionServer-side effect
session/turnStartedBegins agent processing for the new turn
session/permissionResolvedUnblocks the pending tool execution
session/turnCancelledAborts the in-progress turn
session/modelChangedChanges the model for subsequent turns

Released under the MIT License.