Skip to content

Feat/resources and prompts #5

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

jem-computer
Copy link

adds support for Resources and Prompts in useMCP hook

Motivation and Context

see #4

How Has This Been Tested?

  • the Inspector example has been updated to fetch resources and prompts. I've tried it with a real-world example of https://docs.mcp.cloudflare.com/sse, and also connecting to a local toy MCP server that exposes Resources & Prompts

Breaking Changes

N/A

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

  • should we grab resources & prompts from the main useMCP hook or something like usePrompts(…)

jem-computer and others added 5 commits June 19, 2025 18:35
- Add Resource and ResourceTemplate types from MCP SDK
- Add resources and resourceTemplates arrays to UseMcpResult
- Fetch resources automatically after tools during connection
- Add listResources() method to manually refresh resources list
- Add readResource(uri) method to read resource contents
- Clear resources state on disconnect

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Prompt type from MCP SDK
- Add prompts array to UseMcpResult
- Fetch prompts automatically after resources during connection
- Add listPrompts() method to manually refresh prompts list
- Add getPrompt(name, args) method to get specific prompt messages
- Clear prompts state on disconnect

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Import and export Resource, ResourceTemplate, and Prompt types
- Add state management for resources and prompts in McpServers component
- Add UI sections to display available resources and prompts
- Implement readResource functionality with content display
- Implement getPrompt functionality with argument inputs
- Show resource templates with visual distinction
- Add expand/collapse UI for resources and prompts
- Display prompt messages with proper formatting

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Wrap resources/list and prompts/list calls in try-catch blocks
- Continue with connection even if server doesn't support these methods
- Update logging to only show counts for features that are supported
- Fix TypeScript types for optional responses

This allows the hook to work with servers that only implement the core
tools functionality without resources or prompts support.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add resources, resourceTemplates, and prompts to all feature lists
- Document new properties returned by useMcp hook
- Document new methods: listResources, readResource, listPrompts, getPrompt
- Add code examples showing how to use resources and prompts
- Update quick start examples to demonstrate all features
- Add note about graceful handling of servers with partial MCP support

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

Co-Authored-By: Claude <noreply@anthropic.com>
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