Skip to content

Refactor: Extract Capabilities object #42

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

Conversation

kfischer-okarin
Copy link
Contributor

I extracted a Capabilities object, which allows setting the capabilities from the server incrementally and encapsulates the actual calculation of the final capabilities hash.

Motivation and Context

The current determine_capabilities approach would need to become a bit more complex to support all the sub-capabilities without interfering with the already supported auto-determination. This would need a bit of custom bookkeeping which if kept in the server would cause quite a bit of cognitive noise. So I extracted it to its own object with an idempotent "support_..." API.

This is originally thought as a refactor to prepare for easy implementation of the Server#support_notifications method I proposed in #33 - but even if that API should not be adopted after all, I still think it's nice to hide all that capability determination logic in its own object.

How Has This Been Tested?

I did not test this manually, but the existing unit tests still pass.

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

None

kfischer-okarin and others added 2 commits June 4, 2025 22:52
Refactor capabilities handling into MCP::Server::Capabilities to improve
code organization and separation of concerns. This provides a cleaner API
for configuring server capabilities including prompts, resources, tools,
completions, logging, and experimental features.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kfischer-okarin
Copy link
Contributor Author

BTW I had some help from Claude Code (as pointed out in the commit, too), especially with writing out all the Unit Tests - feel free to delete some of them if you find them too extensive

@atesgoral atesgoral merged commit d2c4d3e into modelcontextprotocol:main Jun 5, 2025
5 checks passed
@kfischer-okarin kfischer-okarin deleted the extract-capabilities-object branch June 6, 2025 15:01
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.

2 participants