Examples
This directory contains example code demonstrating how to use the MCP ProcFS Server.
Files
basic-usage.ts
TypeScript example showing how to use the ProcFS reader and writer libraries directly.
Run:
cd /path/to/mcp-proc
npm install
npm run build
npx tsx examples/basic-usage.ts
python-client.py
Python example demonstrating how to interact with the HTTP API.
Requirements:
pip install requests
Run:
# Start the server first
npm run start:sse
# In another terminal
python examples/python-client.py
monitoring-dashboard.js
Real-time system monitoring dashboard using Server-Sent Events (SSE).
Requirements:
npm install eventsource node-fetch
Run:
# Start the server first
npm run start:sse
# In another terminal
node examples/monitoring-dashboard.js
mcp-config.json
Example MCP client configuration file. Use this with MCP-compatible clients like Claude Desktop.
Usage:
- Copy to your MCP client config location
- Update the path to point to your installation
- Restart your MCP client
For Claude Desktop on macOS:
cp examples/mcp-config.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
More Examples
Using cURL
# Start the HTTP server
npm run start:sse
# Get CPU information
curl http://localhost:3000/api/cpu
# Get memory info
curl http://localhost:3000/api/memory
# Read a sysctl parameter
curl http://localhost:3000/api/sysctl/kernel.hostname
# Write a sysctl parameter (requires permissions)
curl -X POST http://localhost:3000/api/sysctl \
-H "Content-Type: application/json" \
-d '{"key": "vm.swappiness", "value": 10}'
Using JavaScript Fetch API
// Get CPU information
const response = await fetch('http://localhost:3000/api/cpu');
const data = await response.json();
console.log(data);
// Write sysctl parameter
await fetch('http://localhost:3000/api/sysctl', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
key: 'net.ipv4.ip_forward',
value: 1
})
});
Using the MCP Protocol
# Start the MCP server on stdio
npm start
# Send a JSON-RPC request (via stdin)
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | npm start
Interactive API Documentation
The HTTP server includes interactive Swagger documentation:
- Start the server:
npm run start:sse - Open browser: http://localhost:3000/api-docs
- Try out the endpoints directly from the browser
Need Help?
- Check the API Documentation
- See Quick Start Guide
- Review the main README