0.3.0 • Published 9 months ago
@odgrim/mcp-fetch v0.3.0
MCP Fetch
A TypeScript implementation of an MCP server that fetches web content using Puppeteer and converts it to markdown.
Useful for breaking your LLM out of infinite "search loops"- you can just tell it to read a doc directly after initial context as a tool!
Features
- Uses Puppeteer to fetch and render web pages, including JavaScript-heavy sites
- Extracts text content from web pages
- Converts HTML content to Markdown format
- Provides both stdio and SSE transport for MCP communication
Installation
npm install @odgrim/mcp-fetchOr install globally:
npm install -g @odgrim/mcp-fetchUsage
As an MCP server with stdio transport
mcp-fetchAs an MCP server with SSE transport
mcp-fetch --sseYou can specify a custom port:
mcp-fetch --sse --port=3001Running with npx (without installing)
You can run the package directly using npx without installing it:
# Run with stdio transport
npx @odgrim/mcp-fetch
# Run with SSE transport
npx @odgrim/mcp-fetch --sse
# Run with SSE transport on a specific port
npx @odgrim/mcp-fetch --sse --port=3001If you're in the project directory during development:
# Run with stdio transport
npx .
# Run with SSE transport
npx . --sseAs a library
import { fetchUrl } from '@odgrim/mcp-fetch';
// Fetch a URL and convert to markdown
const result = await fetchUrl('https://example.com');
console.log(result.markdown);API
MCP Tools
fetch_url
Fetches a URL using Puppeteer and returns the content as markdown.
Parameters:
url(string): The URL to fetchtimeout(number, optional): Timeout in milliseconds (default: 30000)waitForSelector(string, optional): CSS selector to wait forincludeImages(boolean, optional): Whether to include image references in markdown (default: false)
Returns:
- Markdown representation of the page content
fetch-resources
Resource URI pattern: fetch://{url}
Fetches a URL and returns the content.
Development
Prerequisites
- Node.js 14.16.0 or later
Setup
git clone https://github.com/odgrim/mcp-fetch.git
cd mcp-fetch
npm installBuild
npm run buildTesting
npm testRun in development mode
npm run devLicense
MPL-2.0