| name | example-web-search |
| description | Example MCP tool wrapper for web content fetching and search. Demonstrates how to integrate the fetch MCP server for web search capabilities. |
| iface | [object Object] |
| mcp | [object Object] |
| slo | [object Object] |
| limits | [object Object] |
Example Web Search (example-web-search)
Purpose
Demonstrates integration with the fetch MCP server to retrieve and process web content. This example shows how to wrap an MCP tool for web search/fetch operations, including URL fetching, content extraction, and result formatting.
When to Use
- Need to fetch content from a web URL
- Require web search capabilities in an agent workflow
- Want to integrate external web data into skill processing
- Building workflows that combine web data with other skills
Prerequisites
- The
fetchMCP server must be configured in.mcp/servers/fetch.yaml - Internet connectivity for accessing web resources
- Input conforms to
contracts/web_search_query.schema.json - Rate limits configured to respect web service constraints
Procedures
Procedure 1: Fetch Web Content
- Validate Input - Ensure the query payload includes a valid URL or search query
- Prepare Fetch Request - Extract URL and optional parameters (user agent, headers, etc.)
- Call Fetch Tool - Invoke the fetch MCP server to retrieve web content
- Extract Content - Parse the returned HTML/text and extract relevant information
- Format Results - Transform raw content into structured output matching the schema
- Validate Output - Ensure the result conforms to the output contract
Procedure 2: Error Handling
- Handle HTTP errors (404, 500, etc.) gracefully
- Manage timeouts and network failures
- Return partial results when available
- Log failures with sufficient context for debugging
Examples
Example 1: Fetch URL Content
- Input: resources/examples/in.json
{ "url": "https://example.com", "extract_text": true } - Process:
- Validate URL format
- Call fetch MCP tool with URL
- Extract text content from HTML
- Format as structured result
- Output: resources/examples/out.json
{ "url": "https://example.com", "title": "Example Domain", "content": "This domain is for use in illustrative examples...", "metadata": { "status_code": 200, "content_type": "text/html" } }
Implementation Notes
MCP Server Integration
This skill uses the fetch MCP server configured in .mcp/servers/fetch.yaml. The fetch server provides tools for:
- Fetching web content from URLs
- Converting HTML to markdown or plain text
- Handling redirects and error responses
- Respecting robots.txt and rate limits
Rate Limiting
The skill is configured with a rate limit of 30 requests/minute to avoid overwhelming external web services and to respect the MCP server's capacity.
Content Processing
The implementation demonstrates:
- URL validation
- HTML content extraction
- Text normalization
- Metadata extraction (status codes, content types, etc.)
Additional Resources
.mcp/servers/fetch.yaml- Fetch MCP server configuration- MCP Fetch Server Documentation: https://github.com/modelcontextprotocol/servers/tree/main/src/fetch
catalog/skills/_template/mcp-tool-template/- Template for creating new MCP tools
Troubleshooting
- URL Not Accessible: Verify the URL is reachable and not behind a firewall
- Rate Limit Errors: Reduce request frequency or increase rate limit in configuration
- Content Extraction Failures: Check if the target website has changed its HTML structure
- MCP Server Not Available: Ensure fetch server is configured in
.mcp/servers/fetch.yaml - Timeout Errors: Increase latency threshold for slow websites