home / mcp / psutil mcp server
Simple example of using an agent with a local MCP server
Configuration
View docs{
"mcpServers": {
"benedatllc-agent-with-mcp-example": {
"url": "http://localhost:8000/mcp",
"headers": {
"OPENAI_API_KEY": "YOUR_API_KEY"
}
}
}
}This MCP server exposes a small set of system resource tools via FastAPI endpoints and makes them accessible through MCP. You can query CPU times and memory statistics from a local MCP server and interact with them through an MCP client or debugging tool, enabling quick insights into your system resources.
You access the server’s tools by connecting an MCP client to the local MCP URL. The server provides endpoints you can call to retrieve system resource metrics such as CPU times and memory usage. In practice, you start the MCP server locally, then use either an MCP shell or a client integrated with MCP to call the available tools. The primary tool exposed is cpu_times, which returns the total user, system, idle, and other CPU time statistics across all CPUs. You can ask follow-up questions about the results to get more context or drill into specific time ranges.
Prerequisites you need before starting are installed and available on your system.
Install required tools
- uv: package and environment manager for Python
- direnv: environment variable manager for projects
- mcptools: MCP client utility for testing and debugging (optional)
Ensure you have an active OpenAI account and API key if you plan to use the Agent with OpenAI modelsTo run the MCP server, start the process that serves the MCP endpoints. Then you can test the available tools locally with the MCP client.
# Start the MCP server on port 8000
uv run psutil_mcp.py
# In a separate terminal, you can also start the chat frontend if you want to interact with the agent
uv run chat.py
```}],"language":null},{The server and agent support debugging and customization through command line options. Run each program with the --help flag to see available options, including changing the model, ports, and debugging toggles.
Returns total CPU time usage across all CPUs, including user, system, nice, idle, and other time attributes.
Provides memory statistics such as total, used, and available memory on the system.