Sponsored by Deepsite.site

Osquery MCP Server

Created By
kousen6 months ago
MCP wrapper for osquery
Content

Osquery MCP Server

A Spring Boot application that provides a Model Context Protocol (MCP) server interface for Osquery, enabling AI assistants to answer system diagnostic questions using natural language.

Overview

The Osquery MCP Server acts as an intelligent bridge between AI models and your operating system. It translates natural language questions like "Why is my fan running so hot?" or "What's using all my memory?" into precise Osquery SQL queries, giving AI assistants the ability to diagnose system issues, monitor performance, and investigate security concerns.

Features

  • Natural Language System Diagnostics: Ask questions like "What's using my CPU?" and get intelligent answers
  • 8 Specialized Tools for common diagnostic scenarios:
    • Execute custom Osquery SQL queries
    • Get table schemas and available columns
    • Find high CPU/memory usage processes
    • Analyze network connections
    • Check system temperature and fan speeds (macOS)
    • Access example queries for common problems
  • Smart Query Assistance: Built-in examples and schema discovery help the AI construct better queries
  • STDIO-based MCP Integration: Works seamlessly with Claude Desktop and other MCP-compatible AI tools
  • Spring Boot 3.5 with Java 21: Modern, efficient, and maintainable codebase
  • Comprehensive Testing: Includes automated tests with debug logging support

Prerequisites

  • Java 21 or higher
  • Osquery installed and osqueryi available in your PATH
  • Gradle (or use the included Gradle wrapper)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/OsqueryMcpServer.git
cd OsqueryMcpServer
  1. Build the project:
./gradlew build
  1. Run the application:
./gradlew bootRun

Usage

The server operates in STDIO mode and provides 8 specialized tools for system diagnostics:

Core Tools

  • executeOsquery(sql): Execute any valid Osquery SQL query
  • listOsqueryTables(): Get all available Osquery tables on your system
  • getTableSchema(tableName): Discover columns and types for any table

Diagnostic Tools

  • getHighCpuProcesses(): Find processes consuming the most CPU
  • getHighMemoryProcesses(): Find processes using the most memory
  • getNetworkConnections(): Show active network connections with process info
  • getTemperatureInfo(): Get system temperature and fan speeds (macOS)

Helper Tools

  • getCommonQueries(): Get example queries for common diagnostic scenarios

Example AI Interactions

Instead of writing complex SQL, you can now ask natural language questions:

"Why is my computer running slowly?" → AI uses getHighCpuProcesses() and getHighMemoryProcesses()

"What's connecting to the internet?" → AI uses getNetworkConnections()

"Why is my fan so loud?" → AI uses getTemperatureInfo() to check system temps

"Show me all Chrome processes" → AI uses executeOsquery() with schema discovery

Configuration

The application is configured through src/main/resources/application.properties:

  • Server Name: osquery-server
  • Version: 1.0.0
  • Mode: SYNC (synchronous operation)
  • Transport: STDIO (standard input/output)

MCP Integration

This server implements the Model Context Protocol (MCP) using Spring AI's MCP Server starter. It can be integrated with AI tools that support MCP, such as:

  • Claude Desktop App
  • Other MCP-compatible AI assistants

Example MCP Configuration

For Claude Desktop, add to your configuration:

{
  "mcpServers": {
    "osquery": {
      "command": "java",
      "args": ["-jar", "path/to/osquery-mcp-server.jar"]
    }
  }
}

Security Considerations

⚠️ Warning: This server executes system commands with the privileges of the running user. Consider the following security measures:

  • Run with minimal required privileges
  • Implement query filtering or whitelisting in production
  • Monitor and log all executed queries
  • Consider using read-only Osquery queries

Development

Project Structure

├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── com/kousenit/osquerymcpserver/
│   │   │       ├── OsqueryMcpServerApplication.java
│   │   │       └── OsqueryService.java
│   │   └── resources/
│   │       └── application.properties
│   └── test/
│       └── java/
└── build.gradle.kts

Running Tests

./gradlew test

Built-in Diagnostic Queries

The server includes pre-built queries for common diagnostic scenarios. Use getCommonQueries() to see all available examples:

Performance Analysis

-- Top CPU consuming processes
SELECT name, pid, uid, cpu_time FROM processes ORDER BY cpu_time DESC LIMIT 10

-- Memory usage by process  
SELECT name, pid, resident_size, total_size FROM processes ORDER BY resident_size DESC LIMIT 10

Network Analysis

-- Active network connections
SELECT pid, local_address, local_port, remote_address, remote_port, state 
FROM process_open_sockets WHERE state = 'ESTABLISHED'

System Information

-- Overall system info
SELECT hostname, cpu_brand, physical_memory, hardware_vendor, hardware_model FROM system_info

-- Recent file changes
SELECT path, mtime, size FROM file WHERE path LIKE '/Users/%' 
AND mtime > (strftime('%s', 'now') - 3600)

The AI can use these as templates or call the specialized diagnostic tools directly.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License. See License for details.

Acknowledgments

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
ChatWiseThe second fastest AI chatbot™
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
Amap Maps高德地图官方 MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
DeepChatYour AI Partner on Desktop
WindsurfThe new purpose-built IDE to harness magic
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.