- Remove mkdocs files (requirements.txt, CNAME) - Add CLI documentation: build.md, release.md, php.md, run.md - Add configuration.md with full reference - Add examples/ directory with sample configurations: - go-cli-release.yaml - wails-desktop-release.yaml - php-laravel-release.yaml - linuxkit-server.yml - linuxkit-docker-format.yml - full-release.yaml - minimal-release.yaml - official-repos.yaml - Flatten existing framework docs into framework/ - Update index.md as CLI entry point Ready for VitePress integration with core-php/docs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.3 KiB
3.3 KiB
MCP Service
The MCP service (pkg/mcp) implements the Model Context Protocol, enabling AI assistants like Claude to interact with your application.
Overview
MCP provides a standardized way for AI tools to:
- Execute operations in your application
- Query application state
- Interact with the UI
- Manage files and processes
Basic Setup
import "github.com/Snider/Core/pkg/mcp"
// Create standalone MCP server
mcpService := mcp.NewStandaloneWithPort(9877)
// Or integrate with Core
c, _ := core.New(
core.WithService(mcp.NewService),
)
Available Tools
The MCP service exposes numerous tools organized by category:
File Operations
| Tool | Description |
|---|---|
file_read |
Read file contents |
file_write |
Write content to file |
file_edit |
Replace text in file |
file_delete |
Delete a file |
file_exists |
Check if file exists |
dir_list |
List directory contents |
dir_create |
Create directory |
Window Control
| Tool | Description |
|---|---|
window_list |
List all windows |
window_create |
Create new window |
window_close |
Close window |
window_position |
Move window |
window_size |
Resize window |
window_maximize |
Maximize window |
window_minimize |
Minimize window |
window_focus |
Bring to front |
WebView Interaction
| Tool | Description |
|---|---|
webview_eval |
Execute JavaScript |
webview_click |
Click element |
webview_type |
Type into element |
webview_screenshot |
Capture page |
webview_navigate |
Navigate to URL |
webview_console |
Get console logs |
Process Management
| Tool | Description |
|---|---|
process_start |
Start a process |
process_stop |
Stop a process |
process_list |
List running processes |
process_output |
Get process output |
HTTP API
The MCP service exposes an HTTP API:
# Health check
curl http://localhost:9877/health
# List available tools
curl http://localhost:9877/mcp/tools
# Call a tool
curl -X POST http://localhost:9877/mcp/call \
-H "Content-Type: application/json" \
-d '{"tool": "window_list", "params": {}}'
WebSocket Events
Connect to /events for real-time updates:
const ws = new WebSocket('ws://localhost:9877/events');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Event:', data.type, data.data);
};
Integration with Display Service
mcpService := mcp.NewStandaloneWithPort(9877)
mcpService.SetDisplay(displayService)
mcpService.SetWebView(webviewService)
Example: Claude Integration
When Claude connects via MCP, it can:
User: "Move the settings window to the left side of the screen"
Claude uses: window_position("settings", 0, 100)
User: "Take a screenshot of the app"
Claude uses: webview_screenshot("main")
User: "Click the submit button"
Claude uses: webview_click("main", "#submit-btn")
Security Considerations
- MCP server binds to localhost by default
- No authentication (designed for local AI assistants)
- Consider firewall rules for production
Configuration
// Custom port
mcp.NewStandaloneWithPort(8080)
// With all services
bridge := NewMCPBridge(9877, displayService)
bridge.SetWebView(webviewService)