Title: Add `resources` parameter to `MCPServer` by mplemay · Pull Request #2414 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Add `resources` parameter to `MCPServer` by mplemay · Pull Request #2414 · modelcontextprotocol/python-sdk
X Title: Add `resources` parameter to `MCPServer` by mplemay · Pull Request #2414 · modelcontextprotocol/python-sdk
Description: Summary Add constructor-time resource seeding to ResourceManager and wire MCPServer through it so servers can preload concrete resources at initialization, matching the existing tool manager pattern. Motivation and Context This makes resource registration consistent with tool registration and removes the manual loop from MCPServer.__init__. It also makes it easier to create pre-populated servers without adding extra setup code after construction. How Has This Been Tested? uv run --frozen pytest tests/server/mcpserver/resources/test_resource_manager.py uv run --frozen pytest tests/server/mcpserver/test_server.py -k init_with_resources uv run --frozen ruff check src/mcp/server/mcpserver/resources/resource_manager.py src/mcp/server/mcpserver/server.py tests/server/mcpserver/resources/test_resource_manager.py tests/server/mcpserver/test_server.py Breaking Changes None. ResourceManager(resources=...) and MCPServer(resources=...) are additive. 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 Resource seeding now happens inside ResourceManager.__init__, so MCPServer no longer needs a manual registration loop. Duplicate resources continue to flow through add_resource(...), preserving first-write-wins behavior and existing duplicate warnings.
Open Graph Description: Summary Add constructor-time resource seeding to ResourceManager and wire MCPServer through it so servers can preload concrete resources at initialization, matching the existing tool manager patter...
X Description: Summary Add constructor-time resource seeding to ResourceManager and wire MCPServer through it so servers can preload concrete resources at initialization, matching the existing tool manager patter...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2414
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:653e6ae2-e75f-8415-d2ec-5fcdda4cd996 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DB40:1BEC41:AAB1B9:F51539:6A59FBB6 |
| html-safe-nonce | 0cbad55b07cc79834a87d7376eefd3c569349829e9f48b6211ccba1dcb316cc4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjQwOjFCRUM0MTpBQUIxQjk6RjUxNTM5OjZBNTlGQkI2IiwidmlzaXRvcl9pZCI6IjYwNjMzMjc4NzMyNTk0MDQyMTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1d7db1ed58583883d9458d86de0494046df7dcc7bcdb6749286a52a71a8917f2 |
| hovercard-subject-tag | pull_request:3510168158 |
| 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/2414/files |
| twitter:image | https://avatars.githubusercontent.com/u/4324379?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4324379?s=400&v=4 |
| og:image:alt | Summary Add constructor-time resource seeding to ResourceManager and wire MCPServer through it so servers can preload concrete resources at initialization, matching the existing tool manager patter... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4d3f961cfc83a4348ee5be7691cf4ae3515aab3ef5200c13a7e41b048125fb61 |
| 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 | ac4d28603af300ac851b62521abb878ab5d3319a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width