| title |
|---|
Agent Authentication State Query |
- Author(s): @xtmq
What are you proposing to change?
Add an auth/status method and corresponding capability that allows clients to query the agent's current authentication state. This lets clients determine whether the agent is already configured with valid credentials or requires authorization before creating a session, without relying on the ambiguous error behavior of session/new.
How do things work today and what problems does this cause? Why would we change things?
Currently, there is no dedicated way for a client to determine whether an agent has valid authentication configured. The typical workaround is:
- Call
initialize - Call
session/new - If the agent has no credentials, it may return an authorization error
- The client handles the error and initiates an authorization flow
This approach has significant problems:
- Unreliable detection: The
session/newmethod is not required by the specification to check authorization. Some agents validate credentials eagerly, others do so lazily (e.g., on the first LLM call). The client cannot rely onsession/newto consistently surface auth issues. - Wasted resources: Creating a session only to discard it on auth failure is wasteful, especially if session creation has side effects (resource allocation, logging, history file creation, etc.).
- Poor user experience: The client cannot proactively guide the user through authorization before session creation. Instead, users encounter errors mid-flow.
How will things play out once this feature exists?
Clients will be able to:
- Discover whether an agent supports auth state queries via capabilities during initialization
- Query the agent's current authentication state immediately after initialization
- Make an informed decision about whether to proceed with session creation, initiate an authorization flow, or configure endpoints (e.g., via
setLlmEndpoints) - Provide clear, proactive UX — e.g., showing a "Sign in" prompt before any session is created
- Completely skip authentication process if the agent is already authenticated
Tell me more about your implementation. What is your detailed implementation plan?
The client calls initialize, inspects capabilities to confirm auth/status support, then queries auth state before deciding how to proceed.
sequenceDiagram
participant Client
participant Agent
Client->>Agent: initialize
Note right of Agent: Agent reports capabilities,<br/>including auth/status support
Agent-->>Client: initialize response<br/>(agentCapabilities.auth.status)
Client->>Agent: auth/status
Agent-->>Client: auth/status response<br/>(authenticated, authMethods)
alt Authenticated
Client->>Agent: session/new
else Not authenticated
Note over Client: Client initiates<br/>authorization flow<br/>(e.g., call authenticate, setLlmEndpoints)
Client->>Agent: authenticate
Client->>Agent: session/new
end
- Initialization: The client calls
initialize. The agent responds with capabilities, includingauth/statussupport viaagentCapabilities.auth. - Auth state query: The client calls
auth/status. The agent inspects its local configuration, stored credentials, or environment to determine the current auth state. - Client-side decision: Based on the response, the client either proceeds to session creation or initiates an authorization flow first.
The agent advertises support for the auth/status method via the existing auth capability in agentCapabilities:
interface AuthCapabilities {
// ... existing fields (e.g., terminal) ...
/**
* Auth status query support.
* If true, the agent supports the auth/status method.
*/
status?: boolean;
}Initialize Response example:
{
"jsonrpc": "2.0",
"id": 0,
"result": {
"protocolVersion": 1,
"agentInfo": {
"name": "MyAgent",
"version": "2.0.0"
},
"agentCapabilities": {
"auth": {
"status": true
},
"sessionCapabilities": {}
}
}
}A method that can be called after initialization to query the agent's current authentication state.
interface AuthMethodState {
/**
* The ID of the authentication method.
* Corresponds to an `id` from the `authMethods` array returned during initialization.
*/
authMethodId: string;
/**
* Whether the agent has credentials configured for this auth method.
* true means credentials are present (validity is not guaranteed).
*/
authenticated: boolean;
/** Human-readable description of the auth state (e.g., "API key configured via environment") */
message?: string;
/** Extension metadata */
_meta?: Record<string, unknown>;
}
interface AuthStatusRequest {
/** Extension metadata */
_meta?: Record<string, unknown>;
}
interface AuthStatusResponse {
/**
* Whether the agent has credentials configured.
* true means credentials are present (validity is not guaranteed).
* false means no credentials are configured.
*/
authenticated: boolean;
/**
* Optional per-auth-method breakdown of auth state.
* Each entry corresponds to an auth method from the `authMethods` array
* returned during initialization.
*/
authMethods?: AuthMethodState[];
/** Human-readable description of the overall auth state */
message?: string;
/** Extension metadata */
_meta?: Record<string, unknown>;
}{
"$defs": {
"AuthMethodState": {
"description": "Authentication state for a specific auth method.",
"properties": {
"authMethodId": {
"type": "string",
"description": "The ID of the authentication method, matching an entry from the authMethods array returned during initialization."
},
"authenticated": {
"type": "boolean",
"description": "Whether credentials are configured for this auth method."
},
"message": {
"type": ["string", "null"],
"description": "Human-readable description of the auth state."
},
"_meta": {
"additionalProperties": true,
"type": ["object", "null"]
}
},
"required": ["authMethodId", "authenticated"],
"type": "object"
},
"AuthStatusResponse": {
"description": "Response to auth/status method.",
"properties": {
"authenticated": {
"type": "boolean",
"description": "Whether the agent has credentials configured."
},
"authMethods": {
"type": ["array", "null"],
"description": "Per-auth-method state breakdown.",
"items": {
"$ref": "#/$defs/AuthMethodState"
}
},
"message": {
"type": ["string", "null"],
"description": "Human-readable description of the overall auth state."
},
"_meta": {
"additionalProperties": true,
"type": ["object", "null"]
}
},
"required": ["authenticated"],
"type": "object"
}
}
}auth/status Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "auth/status",
"params": {}
}auth/status Response (authenticated):
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"authenticated": true,
"authMethods": [
{
"authMethodId": "anthropic-api-key",
"authenticated": true,
"message": "API key configured via local config"
}
]
}
}auth/status Response (unauthenticated):
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"authenticated": false,
"message": "No credentials configured. Please provide API keys or configure an LLM endpoint."
}
}-
Capability advertisement: The agent SHOULD include
auth.statusinagentCapabilitiesif it supports theauth/statusmethod. Clients MUST check for this capability before calling the method. -
Timing: The
auth/statusmethod MUST be callable afterinitialize. It MAY be called multiple times (e.g., afterauthenticate, to re-check state). -
Local checks only: The agent MAY determine auth state based on locally available information (config files, environment variables, stored tokens) or by making external API calls.
authenticated: truemeans credentials are present, NOT that they are guaranteed to be valid. -
No side effects: Calling
auth/statusMUST NOT modify any agent state. It is a pure query. -
Per-auth-method breakdown: The
authMethodsfield is optional. Agents that support multiple authentication methods MAY include per-method state to help clients make fine-grained decisions.
The current design includes an optional authMethods field with per-auth-method state. However, for many agents a single aggregate state may be enough. A per-method breakdown adds complexity to both the agent implementation and client logic. Should we simplify to just the top-level state and message?
What questions have arisen over the course of authoring this document?
The session/new method is designed for session creation, not for auth validation. Per the specification, agents are not required to validate credentials during session creation — some agents defer validation to the first actual LLM call. This means a successful session/new does not guarantee the agent is authenticated, and a failed session/new may fail for reasons unrelated to authentication. A dedicated method provides a clear, unambiguous signal.
The initialize response contains capabilities — what the agent supports. Auth state is runtime information — what the agent currently has configured. Mixing these concerns would make initialize less predictable. Additionally, auth state may change after initialization (e.g., after a setLlmEndpoints call), and a separate method allows re-querying.
Agents may obtain credentials from many sources: config files, keychains, OAuth tokens, environment variables, or even embedded keys. The client has no visibility into these mechanisms. Only the agent knows whether it has usable credentials configured.
- 2026-03-10: Rename
getAuthStatetoauth/status, nest capability underagentCapabilities.auth - 2026-03-07: Address review feedback, replace per-provider breakdown with per-auth-method
- 2026-03-05: Initial draft — preliminary proposal to start discussion