Skip to content

feat: add missing SetPrompts, DeleteResources, and SetResources methods #445

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

Merged

Conversation

vasayxtx
Copy link
Contributor

@vasayxtx vasayxtx commented Jun 24, 2025

Description

Adds missing methods to achieve complete API parity across Tools, Prompts, and Resources in MCPServer:

  • SetPrompts: Atomically replaces all existing prompts with provided list
  • DeleteResources: Removes multiple resources by URI
  • SetResources: Atomically replaces all existing resources with provided list

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • MCP spec compatibility implementation
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Tests only (no functional changes)
  • Other (please describe):

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly

Summary by CodeRabbit

  • New Features
    • Introduced options to add, delete, and replace resources and prompts on the server.
  • Improvements
    • The server now automatically notifies all active sessions when resource or prompt lists change.
  • Tests
    • Added comprehensive tests to verify resource and prompt management and notification behaviors.

Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

"""

Walkthrough

This change adds batch management methods to MCPServer for resources and prompts, including deleting multiple resources, replacing all resources, and replacing all prompts. It also sends notifications to active sessions when resource or prompt lists change. Comprehensive tests for these new behaviors are included.

Changes

Files Change Summary
server/server.go Added DeleteResources, SetResources, and SetPrompts methods for batch resource and prompt management.
server/server_test.go Added TestMCPServer_Resources and extended TestMCPServer_Prompts to verify notifications and list updates.

Possibly related PRs

  • mark3labs/mcp-go#266: Modifies single-item resource removal to avoid unnecessary notifications; related to resource deletion and notification logic here.
  • mark3labs/mcp-go#320: Adds batch prompt removal (DeletePrompts); complements batch prompt and resource management in this PR.
  • mark3labs/mcp-go#141: Adds single-item resource removal method; related to resource deletion but at different granularity.

Suggested reviewers

  • ezynda3
  • pottekkat
  • robert-jackson-glean
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2eaf2b3 and af97501.

📒 Files selected for processing (2)
  • server/server.go (2 hunks)
  • server/server_test.go (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/server.go
🧰 Additional context used
🧠 Learnings (1)
server/server_test.go (3)
Learnt from: octo
PR: mark3labs/mcp-go#149
File: mcptest/mcptest.go:0-0
Timestamp: 2025-04-21T21:26:32.945Z
Learning: In the mcptest package, prefer returning errors from helper functions rather than calling t.Fatalf() directly, giving callers flexibility in how to handle errors.
Learnt from: ezynda3
PR: mark3labs/mcp-go#461
File: server/sampling.go:22-26
Timestamp: 2025-06-30T07:13:17.052Z
Learning: In the mark3labs/mcp-go project, the MCPServer.capabilities field is a struct value (serverCapabilities), not a pointer, so it cannot be nil and doesn't require nil checking. Only pointer fields within the capabilities struct should be checked for nil.
Learnt from: lariel-fernandes
PR: mark3labs/mcp-go#428
File: www/docs/pages/servers/prompts.mdx:218-234
Timestamp: 2025-06-20T20:39:51.870Z
Learning: In the mcp-go library, the GetPromptParams.Arguments field is of type map[string]string, not map[string]interface{}, so direct string access without type assertions is safe and correct.
🔇 Additional comments (2)
server/server_test.go (2)

965-1008: LGTM! Well-structured test for SetPrompts method.

The test case follows established patterns and comprehensively validates the SetPrompts functionality, including proper notification behavior and final state verification.


1044-1247: LGTM! Comprehensive test coverage for new resource management methods.

This new test function provides excellent coverage for the newly added DeleteResources and SetResources methods. The test cases are well-structured and validate:

  • Proper notification behavior for resource deletions and updates
  • Correct handling of single and multiple resource operations
  • No-op behavior when attempting to delete non-existent resources
  • Atomic replacement behavior of SetResources

The implementation follows established testing patterns and maintains consistency with the existing codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vasayxtx
Copy link
Contributor Author

Hi @ezynda3, @pottekkat,
Could you please review/merge this? I need SetPrompts and SetResources to safely update data without races in my project.
Thanks!

@vasayxtx vasayxtx force-pushed the new-prompt-and-resource-related-methods branch from 05a784f to 2eaf2b3 Compare July 20, 2025 10:35
Complete method parity across Tools, Prompts, and Resources:
- SetPrompts/SetResources atomically replace all existing items
- DeleteResources removes multiple resources by URI
- Add comprehensive tests following existing patterns
@vasayxtx vasayxtx force-pushed the new-prompt-and-resource-related-methods branch from 2eaf2b3 to af97501 Compare July 20, 2025 11:49
@ezynda3 ezynda3 merged commit a3d34d9 into mark3labs:main Aug 12, 2025
4 checks passed
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