Skip to content

Conversation

JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Sep 22, 2025

Summary

This PR updates the MCP parser to support all methods from the latest MCP specification (2025-06-18).

Changes

New Methods Added

  • elicitation/create: Support for user input requests with structured schemas
  • sampling/createMessage: Message creation with model preferences
  • resources/subscribe and resources/unsubscribe: Resource subscription management
  • resources/templates/list: Template listing support
  • roots/list: Root listing functionality
  • notifications/progress: Progress notification handling with string/numeric tokens
  • notifications/cancelled: Cancellation notification support
  • notifications/prompts/list_changed, notifications/resources/list_changed, notifications/resources/updated, notifications/tools/list_changed: Various list change notifications

Improvements

  • Enhanced completion/complete handler to properly handle both PromptReference and ResourceTemplateReference types as specified in the latest schema
  • Added static resource IDs for notification methods that don't require parameter parsing

Testing

  • Added comprehensive test coverage for all new methods
  • Tests verify proper extraction of resource IDs and arguments for each method type
  • All existing tests continue to pass

Testing Done

  • ✅ All unit tests pass (go test ./pkg/mcp/...)
  • ✅ Linting passes (golangci-lint run --fix ./pkg/mcp/...)
  • ✅ Test coverage includes all new methods with various parameter combinations

References

Add support for new MCP methods from the 2025-06-18 specification:
- elicitation/create for user input requests
- sampling/createMessage for message creation
- resources/subscribe and resources/unsubscribe for resource subscriptions
- resources/templates/list for template listing
- roots/list for listing roots
- notifications/progress for progress notifications
- notifications/cancelled for cancellation notifications
- Additional notification methods for list changes

Update completion/complete handler to properly handle both
PromptReference and ResourceTemplateReference types as specified
in the latest schema.

Add comprehensive test coverage for all new methods to ensure
proper extraction of resource IDs and arguments.
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.61%. Comparing base (7138ac9) to head (1b588f7).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1993      +/-   ##
==========================================
+ Coverage   47.36%   47.61%   +0.25%     
==========================================
  Files         232      232              
  Lines       28644    28705      +61     
==========================================
+ Hits        13568    13669     +101     
+ Misses      14059    14018      -41     
- Partials     1017     1018       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Added tests for all new MCP methods from 2025-06-18 specification
- Added edge case tests for error handling and malformed inputs
- Added tests for JSON-RPC notifications (messages without ID)
- Improved test coverage from ~66% to 91.7% for pkg/mcp
- All parser functions now have 83-100% coverage
@JAORMX JAORMX requested a review from Copilot September 23, 2025 15:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the MCP parser to support the latest MCP specification (2025-06-18) by adding support for new methods and improving existing functionality. The implementation provides comprehensive coverage of all new MCP methods including elicitation, sampling, resource subscription, template listing, and various notification types.

Key Changes

  • New method handlers: Added support for 11 new MCP methods including elicitation/create, sampling/createMessage, resource subscription operations, and notification handling
  • Enhanced completion handler: Improved to support both PromptReference and ResourceTemplateReference types according to the latest schema
  • Static resource mapping: Added static resource IDs for notification methods that don't require parameter parsing

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pkg/mcp/parser.go Core parser implementation with new method handlers and static resource mappings
pkg/mcp/parser_test.go Comprehensive test coverage for all new methods and edge cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Fallback to string ref (legacy support)
if ref, ok := paramsMap["ref"].(string); ok {
return ref, nil
return ref, paramsMap
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The legacy string ref case should return nil for arguments to maintain consistency with the original implementation. The change from returning nil to paramsMap could break existing code that expects nil when only extracting the resource ID.

Suggested change
return ref, paramsMap
return ref, nil

Copilot uses AI. Check for mistakes.

Comment on lines +369 to +371
if token, ok := paramsMap["progressToken"].(float64); ok {
return fmt.Sprintf("%.0f", token), paramsMap
}
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fmt.Sprintf("%.0f", token) could produce unexpected results for large numbers due to scientific notation. Consider using strconv.FormatFloat(token, 'f', 0, 64) for more predictable string conversion of numeric tokens.

Copilot uses AI. Check for mistakes.

Comment on lines +382 to +384
if requestId, ok := paramsMap["requestId"].(float64); ok {
return fmt.Sprintf("%.0f", requestId), paramsMap
}
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fmt.Sprintf("%.0f", requestId) could produce unexpected results for large numbers due to scientific notation. Consider using strconv.FormatFloat(requestId, 'f', 0, 64) for more predictable string conversion of numeric request IDs.

Copilot uses AI. Check for mistakes.

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.

1 participant