diff --git a/README.md b/README.md index 704831c..5e69e96 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ yarn add use-mcp - 🔄 Automatic connection management with reconnection and retries - 🔐 OAuth authentication flow handling with popup and fallback support - 📦 Simple React hook interface for MCP integration +- 🧰 Full support for MCP tools, resources, and prompts +- 📄 Access server resources and read their contents +- 💬 Use server-provided prompt templates - 🧰 TypeScript types for editor assistance and type checking - 📝 Comprehensive logging for debugging - 🌐 Works with both HTTP and SSE (Server-Sent Events) transports @@ -38,8 +41,12 @@ function MyAIComponent() { const { state, // Connection state: 'discovering' | 'pending_auth' | 'authenticating' | 'connecting' | 'loading' | 'ready' | 'failed' tools, // Available tools from MCP server + resources, // Available resources from MCP server + prompts, // Available prompts from MCP server error, // Error message if connection failed callTool, // Function to call tools on the MCP server + readResource, // Function to read resource contents + getPrompt, // Function to get prompt messages retry, // Retry connection manually authenticate, // Manually trigger authentication clearStorage, // Clear stored tokens and credentials @@ -83,6 +90,32 @@ function MyAIComponent() { ))} + + {/* Example: Display and read resources */} + {resources.length > 0 && ( +
{resource.description}
- )} + {resource.description &&{resource.description}
}{resource.uri}
- {resource.mimeType && ( - ({resource.mimeType}) - )} + {resource.mimeType && ({resource.mimeType})}{template.description}
- )} + {template.description &&{template.description}
}{template.uriTemplate}
- {template.mimeType && ( - ({template.mimeType}) - )} + {template.mimeType && ({template.mimeType})}{prompt.description}
- )} + {prompt.description &&{prompt.description}
}
{message.content.text || JSON.stringify(message.content, null, 2)}
diff --git a/src/react/README.md b/src/react/README.md
index 3e15c47..f523ea5 100644
--- a/src/react/README.md
+++ b/src/react/README.md
@@ -23,7 +23,7 @@ The useMcp hook manages the connection to an MCP server, handles authentication
```tsx
import { useMcp } from 'use-mcp'
// Optional: Import types if needed
-import type { UseMcpOptions, UseMcpResult, Tool } from 'use-mcp'
+import type { UseMcpOptions, UseMcpResult, Tool, Resource, ResourceTemplate, Prompt } from 'use-mcp'
```
## Usage
@@ -101,7 +101,12 @@ function MyChatComponent() {
Waiting for authentication...
} - {mcp.state === 'ready' &&Connected! Tools available: {mcp.tools.length}
} + {mcp.state === 'ready' && ( ++ Connected! Tools: {mcp.tools.length}, Resources: {mcp.resources.length + mcp.resourceTemplates.length}, + Prompts: {mcp.prompts.length} +
+ )} {/* Your Chat UI */}