Model Context Protocol Server
MCP server: Model Context Protocol Server
Installation
npx model-context-protocol-serverAsk AI about Model Context Protocol Server
Powered by Claude Β· Grounded in docs
I know everything about Model Context Protocol Server. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCP File & URL Tools
A clean, production-ready MCP (Model Context Protocol) server built with Node.js that provides two essential tools: read_file and fetch_url.
Features
- read_file: Read local files and return their contents as text
- fetch_url: Perform HTTP GET requests with timeout and error handling
- Clean, modular architecture
- Full MCP protocol compliance
- Simple test client included
Project Structure
.
βββ src/
β βββ server.js # MCP server setup and routing
β βββ tools/
β βββ readFile.js # read_file tool implementation
β βββ fetchUrl.js # fetch_url tool implementation
βββ client/
β βββ testClient.js # Simple test client
βββ package.json
βββ README.md
Installation
-
Install Node.js 18+ (for native fetch support)
-
Install dependencies:
npm install
Usage
Running the MCP Server
The server uses stdio transport and follows the MCP protocol:
npm start
# or
node src/server.js
Testing with the Test Client
Run the included test client:
npm test
# or
node client/testClient.js
Tools
Tool 1: read_file
Read a local file and return its contents as text.
Input:
{
"path": "/path/to/file.txt"
}
Output: Returns the file contents as plain text in the MCP response format.
Error Handling:
- File not found (ENOENT)
- Permission denied (EACCES)
- Path is a directory (EISDIR)
- Other file system errors
Tool 2: fetch_url
Perform a GET request to a URL and return the response.
Input:
{
"url": "https://example.com"
}
Output: Returns a JSON object containing:
status: HTTP status codestatusText: HTTP status textheaders: Response headersbody: Response body as text
Features:
- 10 second timeout to prevent hanging requests
- Basic URL validation
- Network error handling
- User-Agent header included
MCP Client Configuration
To use this server with an MCP client, configure it as follows:
{
"mcpServers": {
"file-url-tools": {
"command": "node",
"args": ["path/to/src/server.js"]
}
}
}
Design Decisions
Architecture
- Modular structure: Tools are separated into individual modules for maintainability
- Error handling: Consistent error handling across all tools with clear error messages
- MCP compliance: Uses official MCP SDK and follows protocol specifications
read_file Tool
- Uses
fs/promisesfor async file operations - UTF-8 encoding only (text files)
- Path resolution for relative paths
fetch_url Tool
- Uses Node.js built-in
fetch(Node 18+) - 10 second timeout via AbortController
- Returns complete response info (status, headers, body)
License
MIT
