Skip to content

Feature: Accept Config Variables via Request Headers and Query Parameters (Multi-User) #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from

Conversation

dsaad68
Copy link

@dsaad68 dsaad68 commented Apr 10, 2025

✨ Proposal: Extend MCP Server to Accept Config Variables via Request Headers

This PR introduces a work-in-progress proposal to extend the current MCP server by allowing configuration-related variables to be passed through request headers or query parameters in the request. This proposal addresses issue #205 and builds on #224. Some parts of this implementation are inspired by work from @maxxrdrgz.

✅ What’s included:

  • ContextVar integration: Utilizes Python’s ContextVar to dynamically capture and manage configuration variables provided in the URL query string.
  • In-memory caching: Adds caching support for up to 100 clients, with a TTL of 3600 seconds (1 hour). (This be updated to become configurable or can be adjusted later — either through code or during the server initialization process.)
  • Test updates: Existing tests have been modified to support the new functionality.

🔧 Supported headers and query parameters:

The following headers are currently supported:

  • confluence-username
  • confluence-token
  • confluence-personal-token
  • jira-username
  • jira-token
  • jira-personal-token

How to run the server for example:

uvx mcp-atlassian \
   --transport see --port 9000
  --multi-user
  --confluence-url https://your-company.atlassian.net/wiki \
  --jira-url https://your-company.atlassian.net 

How to add to the client (for example VS Code):

{
  "servers": {
    "mcp-atlassian-sse" :{
      "url": "http://localhost:9000",
      "type": "sse",
      "headers": {
        "jira-username": "jira-username",
        "jira-token": "jira-token"
      }
    }
  }
}

Query parameters from URL:

https://your-server.com/[email protected]&confluence-token=abc123&[email protected]&jira-personal-token=xyz789

📝 To-Dos

  • Extend existing tests and add additional tests for multi-user case
  • Discuss to add Jira/Confluence URL to header or not

dsaad68 and others added 17 commits April 9, 2025 20:49
This is a merge commit the virtual branches in your workspace.

Due to GitButler managing multiple virtual branches, you cannot switch back and
forth between git branches and virtual branches easily. 

If you switch to another branch, GitButler will need to be reinitialized.
If you commit on this branch, GitButler will throw it away.

Here are the branches that are currently applied:
 - Lane (refs/gitbutler/Lane)
   branch head: 62ee847
   - src/mcp_atlassian/__init__.py
For more information about what we're doing here, check out our docs:
https://docs.gitbutler.com/features/virtual-branches/integration-branch
This is placeholder commit and will be replaced by a merge of yourvirtual branches.

Due to GitButler managing multiple virtual branches, you cannot switch back and
forth between git branches and virtual branches easily. 

If you switch to another branch, GitButler will need to be reinitialized.
If you commit on this branch, GitButler will throw it away.

For more information about what we're doing here, check out our docs:
https://docs.gitbutler.com/features/virtual-branches/integration-branch
@dsaad68 dsaad68 changed the title Feature: Multi-User Feature: Accept Config Variables via Request Headers (Multi-User) Apr 10, 2025
@dsaad68 dsaad68 changed the title Feature: Accept Config Variables via Request Headers (Multi-User) Feature: Accept Config Variables via Request Headers and Query Parameters (Multi-User) Apr 10, 2025
@dsaad68
Copy link
Author

dsaad68 commented Apr 10, 2025

@sooperset

I get this mypy error everywhere in every branch I have tested, also on GitHub Actions.
Is there something that's being mismanaged by me?

src/mcp_atlassian/jira/worklog.py:163: error: "Jira" has no attribute "worklog"  [attr-defined]
src/mcp_atlassian/jira/fields.py:152: error: "Jira" has no attribute "createmeta"  [attr-defined]
src/mcp_atlassian/jira/issues.py:881: error: Unexpected keyword argument "fields" for "update_issue" of "Jira"  [call-arg]
/Users/dsaad/.cache/pre-commit/reponj02mz97/py_env-python3.13/lib/python3.13/site-packages/atlassian/jira.py:1472: note: "update_issue" of "Jira" defined here
src/mcp_atlassian/jira/issues.py:1191: error: "Jira" has no attribute "issue_get_transitions"; maybe "get_issue_transitions"?  [attr-defined]
src/mcp_atlassian/jira/epics.py:155: error: "Jira" has no attribute "comments"  [attr-defined]
Found 5 errors in 4 files (checked 88 source files)

@sooperset
Copy link
Owner

Hi @dsaad68,

Thank you for the excellent work on this PR! The use of ContextVar is a solid architectural improvement for handling multi-user contexts, and we appreciate the effort put into caching and supporting various configuration methods.

However, we've decided to hold off on merging multi-user features based on the current HTTP+SSE transport.

The official MCP specification has adopted the new "Streamable HTTP" transport (#206) as the way forward. Our project strategy is to align with this standard for better long-term scalability and compatibility. Implementing multi-user support requires updates to the core modelcontextprotocol/python-sdk (#405) to support Streamable HTTP, which are still pending.

Merging this SSE-based solution now would necessitate significant refactoring once the SDK is updated. To avoid this duplicate work, we plan to implement multi-user support directly on the Streamable HTTP standard once the SDK is ready.

We truly value the architectural foundation laid here and hope to leverage these concepts in the future Streamable HTTP implementation. We'll be closing this PR for now due to the shift in the underlying MCP transport standard.

Thanks again for your substantial contribution and understanding!

@dsaad68
Copy link
Author

dsaad68 commented Apr 15, 2025

@sooperset

I will close this PR.

@dsaad68 dsaad68 closed this Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants