Skip to content

Commit 73751c2

Browse files
authored
Enhance README with usage and configuration details
Expanded the README to include detailed usage instructions, environment variables, configuration examples, and use cases for the MCP Web URL Reader.
1 parent 83a0c2d commit 73751c2

File tree

1 file changed

+157
-15
lines changed

1 file changed

+157
-15
lines changed

README.md

Lines changed: 157 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,170 @@
1-
# mcp-web-url-reader
2-
3-
An MCP server that exposes a single tool, `read_web_url`, which fetches absolute URLs with `curl -sL` after prepending a configurable `CUSTOM_PREFIX` on the server side. This server uses the MCP TypeScript/JavaScript SDK and serves a Streamable HTTP endpoint at `/mcp` for compatibility across many AI applications.
1+
# MCP Web URL Reader
2+
An MCP server that exposes a single tool, `read_web_url`, which fetches absolute URLs with `curl -sL` after prepending a configurable `CUSTOM_PREFIX` on the server side. This server uses the MCP TypeScript/JavaScript SDK and serves a Streamable HTTP endpoint at `/mcp` for compatibility across many AI applications. Perfect for routing AI web requests through proxies, caching layers, or custom gateways.
43

54
## Features
65

7-
- Streamable HTTP transport with session management on `/mcp` (POST for JSON-RPC requests, GET for SSE notifications, DELETE to end sessions).
8-
- CORS enabled with `Mcp-Session-Id` exposed for browser-based clients, as recommended.
9-
- Tool: `read_web_url` with input `{ url: string }`, which runs `curl -sL CUSTOM_PREFIX/<url>` and returns the response text.
10-
- Tiny Docker image based on `node:20-alpine` with `curl` installed via `apk add --no-cache curl`.
6+
- 🌐 Simple web URL reading via curl
7+
- 🔧 Configurable URL prefix for proxying/routing
8+
- 🐳 Tiny Docker image based on Node.js
9+
- 🚀 Easy deployment with Docker Compose
10+
- 🛠️ Compatible with any MCP-enabled AI application
11+
12+
## How It Works
13+
14+
The AI thinks it's reading a normal URL:
15+
```
16+
curl -sL https://www.example.com
17+
```
18+
19+
But the server actually executes:
20+
```
21+
curl -sL CUSTOM_PREFIX/https://www.example.com
22+
```
23+
24+
This allows you to:
25+
- Route requests through a caching proxy
26+
- Add authentication layers
27+
- Use custom gateways
28+
- Bypass rate limits with your own infrastructure
29+
- Monitor/log AI web access
30+
31+
## Quick Start
32+
33+
### Using Docker Compose
34+
35+
See `docker-compose.yml` for a working example service mapping `8080:8080` and injecting both environment variables.
36+
37+
The MCP server will be available at `http://localhost:8080`
38+
39+
### Environment Variables
40+
41+
| Variable | Description | Default |
42+
|----------|-------------|---------|
43+
| `CUSTOM_PREFIX` | URL prefix to prepend to all requests | `""` (empty) |
44+
| `INTERNAL_PORT` | Internal server port | `80800` |
45+
46+
### Configuration Examples
47+
48+
#### Direct Mode (No Prefix)
49+
```yaml
50+
environment:
51+
- CUSTOM_PREFIX=
52+
- PORT=3000
53+
```
54+
55+
#### Proxy Mode
56+
```yaml
57+
environment:
58+
- CUSTOM_PREFIX=https://proxy.myserver.com
59+
- INTERNAL_PORT=8080
60+
```
61+
62+
#### Cache Gateway
63+
```yaml
64+
environment:
65+
- CUSTOM_PREFIX=http://cache-server:8000/fetch
66+
- INTERNAL_PORT=8080
67+
```
68+
69+
## Using with AI Applications, MCP Client Integration
70+
71+
The server exposes tools over Streamable HTTP: initialize a session with a POST to `/mcp`, reuse `Mcp-Session-Id` from the response, then call `tools/call` with `{ name: "read_web_url", arguments: { url: "https://example.com" } }`. The server will run `curl -sL CUSTOM_PREFIX/https://example.com` and return text content. Ensure the `Mcp-Session-Id` header is included in subsequent requests and allowed via CORS.
1172

12-
## Environment Variables
73+
### Claude Desktop (MCP)
1374

14-
- `INTERNAL_PORT` (default: `8080`): Port the HTTP server listens on inside the container. [web:1]
15-
- `CUSTOM_PREFIX` (required for prefixing): The string to prepend before the requested absolute URL, e.g., `https://your-proxy/forward`.
75+
Add to your `claude_desktop_config.json`:
1676

17-
### Run
77+
```json
78+
{
79+
"mcpServers": {
80+
"web-url-reader": {
81+
"url": "http://localhost:8080/mcp"
82+
}
83+
}
84+
}
85+
```
1886

87+
### n8n
88+
89+
Use the MCP Server node and point it to `http://localhost:8080/mcp`
90+
91+
### Custom Applications
92+
93+
Connect to the MCP endpoint at `http://localhost:8080/mcp`
94+
95+
## Tool Schema
96+
97+
The server exposes one tool:
98+
99+
**`read_web_url`**
100+
- Description: Read and return the contents of a web page
101+
- Parameter: `url` (string, required) - The complete URL to fetch
102+
- Returns: Text content of the web page
103+
104+
Example tool call:
105+
```json
106+
{
107+
"name": "read_web_url",
108+
"arguments": {
109+
"url": "https://www.example.com"
110+
}
111+
}
112+
```
113+
114+
## Use Cases
115+
116+
### Caching Layer
117+
Route all AI web requests through your caching server to reduce external calls:
118+
```
119+
CUSTOM_PREFIX=http://cache-server/proxy
120+
```
121+
122+
### Authentication Gateway
123+
Add authentication to web requests:
124+
```
125+
CUSTOM_PREFIX=http://auth-gateway/fetch
126+
```
127+
128+
### Rate Limit Management
129+
Route through your own infrastructure to manage rate limits:
130+
```
131+
CUSTOM_PREFIX=https://ratelimit-proxy.myserver.com
132+
```
133+
134+
### Privacy/Monitoring
135+
Log and monitor all AI web access:
136+
```
137+
CUSTOM_PREFIX=http://monitoring-gateway/fetch
138+
```
139+
140+
## Run
19141
- Open `http://localhost:8080/` for a basic health probe and connect your MCP client to `http://localhost:8080/mcp`.
20142
- The MCP endpoint is on `http://localhost:8080/mcp` with Streamable HTTP semantics for POST/GET/DELETE and CORS exposure for `Mcp-Session-Id`.
21143

22-
## Docker Compose
144+
## Troubleshooting
23145

24-
See `docker-compose.yml` for a working example service mapping `8080:8080` and injecting both environment variables.
146+
### Server won't start
147+
- Check that port 3000 is not in use
148+
- Verify environment variables are set correctly
149+
- Check Docker logs: `docker-compose logs -f`
150+
151+
### Requests failing
152+
- Verify CUSTOM_PREFIX is accessible from container
153+
- Test curl manually: `docker exec -it mcp-web-reader curl -sL YOUR_URL`
154+
- Check timeout settings (default 30s)
155+
156+
### GitHub Actions not building
157+
- Ensure workflow permissions are enabled
158+
- Check that GITHUB_TOKEN has package write access
159+
- Verify Dockerfile syntax
160+
161+
## License
162+
163+
MIT License - Feel free to use and modify as needed.
25164

26-
## MCP Client Integration
165+
## Contributing
27166

28-
The server exposes tools over Streamable HTTP: initialize a session with a POST to `/mcp`, reuse `Mcp-Session-Id` from the response, then call `tools/call` with `{ name: "read_web_url", arguments: { url: "https://example.com" } }`. The server will run `curl -sL CUSTOM_PREFIX/https://example.com` and return text content. Ensure the `Mcp-Session-Id` header is included in subsequent requests and allowed via CORS.
167+
Pull requests welcome! Please ensure:
168+
- Docker image builds successfully
169+
- README is updated for new features
170+
- GitHub Actions workflow passes

0 commit comments

Comments
 (0)