Skip to content

Comments

feat: add resource-based download for MCP patent data#49

Closed
sonesuke wants to merge 1 commit intomainfrom
feat/mcp-resources
Closed

feat: add resource-based download for MCP patent data#49
sonesuke wants to merge 1 commit intomainfrom
feat/mcp-resources

Conversation

@sonesuke
Copy link
Owner

Summary

Add resource-based download pattern for MCP patent data retrieval. Search and fetch operations now return a summary with a resource_id, and a new download_result tool allows downloading the full data on-demand.

Problem

Previously, search_patents and fetch_patent tools returned the full patent data directly in their responses. For large results, this could be inefficient and make tool responses very large.

Solution

Implement a resource-based download pattern:

  1. Search/Fetch: Return summary with resource_id (UUID)
  2. Download: Use download_result tool with resource_id to get full data

This keeps tool responses small and efficient while allowing AI agents to download large data on-demand.

Changes

  • OperationSummary: New struct with hits, total_results, and resource_id
  • In-memory store: HashMap-based store for patent data keyed by UUID
  • search_patents: Returns summary, stores full results with UUID key
  • fetch_patent: Returns summary, stores full results with UUID key (raw mode unchanged)
  • download_result: New tool to retrieve data by resource_id
  • E2E tests: Updated to expect resource_id in responses

Usage Flow

// 1. Search patents
{
  "query": "machine learning",
  "limit": 10
}
// Returns: {"hits": 10, "total_results": "5000", "resource_id": "abc-123"}

// 2. Download full data
{
  "resource_id": "abc-123"
}
// Returns: Full JSON patent data

Compatibility

This pattern is compatible with MCP's resource approach and works with rmcp 0.16. When rmcp adds full resources API support, this can be migrated to use the official list_resources and read_resource methods.

Test plan

  • Pre-commit checks pass (fmt, clippy, test)
  • Unit tests verify summary with resource_id
  • E2E tests updated and passing

🤖 Generated with Claude Code

Add resource-based download pattern for MCP patent data retrieval.
Search and fetch operations now return a summary with a resource_id,
and a new download_result tool allows downloading the full data.

This approach keeps tool responses small and efficient while allowing
AI agents to download large patent data on-demand using the resource_id.

Changes:
- Add OperationSummary struct with hits, total_results, and resource_id
- Add in-memory HashMap store for patent data keyed by resource_id (UUID)
- Update search_patents to return summary and store full results
- Update fetch_patent to return summary and store full results (raw mode unchanged)
- Add download_result tool to retrieve data by resource_id
- Update E2E tests to expect resource_id in responses

Usage flow:
1. AI calls search_patents or fetch_patent
2. Receives summary with resource_id
3. Calls download_result with resource_id to get full JSON data

This pattern is compatible with MCP's resource approach and works
with rmcp 0.16 without requiring full resources API support.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@sonesuke sonesuke closed this Feb 23, 2026
@sonesuke sonesuke deleted the feat/mcp-resources branch February 23, 2026 09:49
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