Title: enable http headers in sse in the context by abdullahkady · Pull Request #216 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: enable http headers in sse in the context by abdullahkady · Pull Request #216 · modelcontextprotocol/python-sdk
X Title: enable http headers in sse in the context by abdullahkady · Pull Request #216 · modelcontextprotocol/python-sdk
Description: Motivation and Context In the server, it seems like a common case to need to access the raw HTTP headers (think a reverse proxy header, or some custom analytics headers). Example use case, where we have two services that can possibly talk to the MCP server. The servers identify themselves through the X-Client HTTP header. from mcp.server.fastmcp import Context, FastMCP mcp = FastMCP("test_w_headers", port=3001, debug=True) @mcp.tool() def add_sales_lead(lead: str, ctx: Context) -> str: """ Adds a new sales lead. Tracks which app was the originator of this request based on the X-Client custom header """ sales.add_lead(lead, tracking_attrs={"src": ctx.headers.get("X-Client")} return "Lead added successfully" How Has This Been Tested? They were just tested manually locally Breaking Changes No Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context
Open Graph Description: Motivation and Context In the server, it seems like a common case to need to access the raw HTTP headers (think a reverse proxy header, or some custom analytics headers). Example use case, where we...
X Description: Motivation and Context In the server, it seems like a common case to need to access the raw HTTP headers (think a reverse proxy header, or some custom analytics headers). Example use case, where we...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/216
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9788189d-38b2-58cc-a076-174682de53e3 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | ABBC:147BEB:7DFEB5:B3BA2B:6A59EF70 |
| html-safe-nonce | 562a4ecd6c8aece9d92a8fe828176c94c1a12606ca43a9a3cbf60d52303087c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkJDOjE0N0JFQjo3REZFQjU6QjNCQTJCOjZBNTlFRjcwIiwidmlzaXRvcl9pZCI6IjcwNTcwMDE0MjY1NzM3MTczNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b10ce85538a3ba54ca54e98a2a21bc0b751f0b60248e99dc083b8ed14d011a69 |
| hovercard-subject-tag | pull_request:2343436029 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/216/files |
| twitter:image | https://avatars.githubusercontent.com/u/15708438?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/15708438?s=400&v=4 |
| og:image:alt | Motivation and Context In the server, it seems like a common case to need to access the raw HTTP headers (think a reverse proxy header, or some custom analytics headers). Example use case, where we... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ba3976babb66479b1c943a8edc0777d96157da48fadc0161f9ddb219deee8353 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 24801cf86623a319252348d1fd69122ad974b842 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width