- 
                Notifications
    You must be signed in to change notification settings 
- Fork 6
Add MCP resource API support to REST endpoints #183
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
      
      
    
                
     Merged
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | 
 | 
14fde23    to
    07ca63e      
    Compare
  
    8ffd371    to
    614a75b      
    Compare
  
    d7984a2    to
    6f2053d      
    Compare
  
    * Add ErrResourceListFailed, ErrResourceReadFailed for server communication errors (502) * Add ErrResourceNotFound for missing resources (404) * Add ErrResourceForbidden for access control violations (403) * Add ErrResourcesNotImplemented for servers without resource capability (501) These errors enable proper HTTP status code mapping in the API layer.
* Add mapping for ErrResourceNotFound → 404 Not Found * Add mapping for ErrResourceForbidden → 403 Forbidden * Add mapping for ErrResourceListFailed → 502 Bad Gateway * Add mapping for ErrResourceReadFailed → 502 Bad Gateway * Add mapping for ErrResourcesNotImplemented → 501 Not Implemented * Add comprehensive test cases for all new error mappings This enables proper REST API status codes for resource-related errors.
* Add Resource, ResourceTemplate, ResourceContent API types with proper JSON tags * Add Meta type alias for consistent metadata handling * Add DomainResource, DomainResourceTemplate, DomainMeta wrapper types * Implement ToAPIType methods with proper MCP spec compliance * Add handleServerResources with cursor-based pagination support * Add handleServerResourceTemplates for URI template discovery * Add handleServerResourceRead for content retrieval * Add method not found detection with temporary string matching * Add comprehensive error handling with proper error wrapping Implements full MCP resource specification for REST API access.
* Add unit tests for handleServerResources with pagination scenarios * Add unit tests for handleServerResourceTemplates * Add unit tests for handleServerResourceRead with multiple content types * Add comprehensive error case testing for all handlers * Extend mockMCPClient to support resource operations * Test proper error propagation and HTTP status mapping * Validate JSON response structure and schema compliance Ensures robust test coverage for all resource API functionality.
* Add resource-related fields to mockMCPClient for testing * Add ListResources, ListResourceTemplates, ReadResource mock methods * Enable comprehensive resource API testing infrastructure This provides the foundation for resource API test coverage.
Add RegisterResourceRoutes call to RegisterServerRoutes to expose:
* GET /api/v1/servers/{name}/resources - List server resources
* GET /api/v1/servers/{name}/resources/templates - List resource templates
* POST /api/v1/servers/{name}/resources/read - Read resource content
This completes the resource API integration into the REST API.
    Add node_modules/ to gitignore for test MCP servers and development tools.
6f2053d    to
    af40a8f      
    Compare
  
    
              
                    dpoulopoulos
  
              
              approved these changes
              
                  
                    Sep 25, 2025 
                  
              
              
            
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Summary:
This PR implements comprehensive support for MCP (Model Context Protocol) resources in the
mcpdREST API, enabling clients to discover and access server resources through standard HTTP endpoints.GET/api/v1/servers/{name}/resources- List server resources with paginationGET/api/v1/servers/{name}/resources/templates- List resource templates for URI discoveryGET/api/v1/servers/{name}/resources/content?uri={uri}- Get resource content by URI404,403,501,502) for resource-specific errorsCloses: #181
NOTE:
If mark3labs/mcp-go#595 is merged and released, then we can also refactor the checks for 'Method not found' in the code.