OptionallocaleUser's preferred locale (BCP 47 format). Use for localization and formatting.
OptionalrawRaw _meta object from the client. Access protocol-specific fields not mapped to typed properties.
OptionalstateShared state map populated by middleware. Middleware can use state.set() to share data with tool handlers.
OptionalsubjectUser identifier from the request context.
When OAuth is configured, this value is server-validated and overrides any client-provided value.
Access full auth details via context.raw?.["mcp-apps-kit/auth"].
handler: async (input, context) => {
// With OAuth: verified user identifier
const userId = context.subject;
// Access full auth context (scopes, clientId, token, etc.)
const auth = context.raw?.["mcp-apps-kit/auth"];
const scopes = auth?.scopes ?? [];
return { message: `Hello, ${userId}!` };
}
OptionaluserClient user agent string. Use for analytics or client-specific formatting. Never rely on this for authentication.
OptionaluserCoarse user location. Use for localization, timezone adjustments, or regional content.
OptionalwidgetWidget session ID for component correlation. Stable across tool calls within the same widget instance.
Context provided by the client during tool invocation
Contains metadata hints from the host platform (ChatGPT, MCP Apps hosts, etc.). All fields are optional as availability depends on the client.
Example