Skip to content

[FEATURE] a customizable OAuth user context to hold sessions #166

@bgaidioz

Description

@bgaidioz

Is your feature request related to a problem?

OAuth MCP projects tend to allocate a locked dictionary, protected by a lock, that is used to hold per-user context like the session to a backend (e.g. calendar). And because sessions could expire and need to be reset, they also implement error handling and reset of these per-user sessions.

The problem is that it feels error prone and brittle to have users implementing that systematically.

Since MXCP is aware of the user issuing the tool call, and it provides the context to tools, I thought the framework could provide convenient hooks to create per-user sessions, implement the mapping, recreate them upon error, without users having to implement all that themselves. If part of the infra, opening/closing sessions could be logged/audited, etc.

Describe the solution you'd like

The same way one can register @on_init, @on_shutdown, there would be a tag that identifies the one function user -> session, creating the backend connection from the user context. And the infra would internally implement the locking around, the maintenance in memory, etc. When a tool is called, the context would automatically be populated with that session?

There would be an annotation to close the session, used to close remaining sessions on shutdown, and also during execution when the dictionary would hit a size limit and would discard existing sessions?

Describe alternatives you've considered

Use Case

Have MXCP be more user-friendly when authentication is used.

Implementation Ideas

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions