The Context object gives you access to request-scoped utilities while a tool/resource/prompt is executing—primarily logging, progress, and request metadata.
Use get_context() to fetch the active context.
Note: get_context() only works inside an active MCP request handler. Calling it elsewhere raises LookupError.
Get Context
In tools (and dependency callables), parameters annotated as Context can be auto-injected by the framework—no need to call get_context() manually:
Available features
Authorization context
If authorization is enabled, ctx.auth_context may be set; otherwise it’s None:
Progress example
Last modified on June 30, 2026