poly-mcp 0.5.0

A comprehensive MCP server with filesystem, diagnostics, scripting, time, network, context, git, input, clipboard, transform, and screen control tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# Poly MCP

A comprehensive MCP (Model Context Protocol) server with 73 tools across 11 modules — filesystem operations, diagnostics, scripting, time management, network utilities, context handling, git operations, user input, agent-centric version control, session clipboard, and text/data transforms.

## Features

### 1. Filesystem Module

Advanced file and directory operations with snapshot management, search, and bulk editing:

- **fs_read** - Read file contents (with optional line ranges)
- **fs_write** - Write content to files (with optional line ranges)
- **fs_move** - Move files or directories
- **fs_copy** - Copy files or directories recursively
- **fs_create** - Create files or directories
- **fs_delete** - Delete files or directories
- **fs_move_desktop** - Organize items within Desktop directory
- **fs_find** - Search for files with pattern matching
- **fs_ld** - Detailed directory listing (like ls -la)
- **fs_stat** - Get file/directory metadata
- **fs_permissions** - Get or set Unix file permissions
- **fs_watch** - Monitor file/directory changes
- **fs_snapshot** - Create timestamped backups with auto-management
- **fs_tree** - Visual directory tree with depth control and pattern filtering
- **fs_grep** - Regex content search across files with context lines
- **fs_tail** - Read last N lines of a file
- **fs_replace** - Bulk find/replace across files with regex and dry-run support

### 2. Diagnostics Module

Language-agnostic error and warning detection:

- **diagnostics_get** - Get errors/warnings for files or projects
- Auto-detects appropriate diagnostic tool (cargo, tsc, eslint, pylint, etc.)
- Supports Rust, TypeScript/JavaScript, Python, C/C++
- Parses compiler/linter output into structured JSON

### 3. Silent Module

Bash scripting and system resource monitoring:

- **silent_script** - Execute bash scripts with arguments, env vars, and timeout
- **silent_resources** - Monitor GPU/RAM/CPU usage with detailed process info
- Supports nvidia-smi for GPU monitoring
- Process filtering and sorting by resource usage

### 4. Time Module

Time management, scheduling, and timekeeping:

- **time_now** - Get current timestamp in multiple formats (Unix, ISO8601, RFC3339, custom)
- **time_sleep** - Delay execution with configurable duration
- **time_schedule** - In-memory task scheduler with create/cancel/list/status operations
- **time_timezone** - Convert timestamps between IANA timezones, list available timezones
- **time_stopwatch** - Named stopwatches with start/stop/lap/reset/status/list
- **time_timer** - Countdown timers with check/cancel/list
- **time_alarm** - Set alarms by time or offset, check/cancel/list

### 5. Network Module

HTTP requests and package registry queries:

- **net_fetch** - Fetch URLs with automatic HTML to Markdown conversion
- **net_cargo** - Query crates.io for Rust package info
- **net_node** - Query npm registry for Node.js packages
- **net_python** - Query PyPI for Python packages
- **net_apt** - Query APT package information
- **net_ping** - Check network connectivity with statistics

### 6. Context Module

Token counting and context management for LLMs:

- **ctx_context** - Track token usage (total/used/left)
- **ctx_compact** - Compress text using zlib/gzip algorithms
- **ctx_remove** - Clear context and reset usage
- **ctx_token_count** - Count tokens for various LLM providers (GPT-4, Claude, etc.)
- **ctx_memory_store** - Store data in-memory (process lifetime)
- **ctx_memory_recall** - Retrieve stored data
- **ctx_estimate_cost** - Estimate API costs for Anthropic, OpenAI, Ollama, GLM

### 7. Git Module

Complete git operations via libgit2:

- **git_status** - Repository status with staged/unstaged/untracked files
- **git_diff** - View changes with patch format
- **git_commit** - Create commits
- **git_branch** - List, create, or delete branches
- **git_checkout** - Switch branches or commits
- **git_blame** - Show line-by-line authorship
- **git_log** - View commit history
- **git_tag** - Manage tags (lightweight and annotated)

### 8. Input Module

User interaction and notifications:

- **input_notify** - Send terminal and desktop notifications
- **input_prompt** - Interactive text prompts (terminal or MCP)
- **input_select** - Selection menus (terminal or MCP)
- **input_progress** - Display progress bars
- **input_clipboard_read** - Read from system clipboard
- **input_clipboard_write** - Write to system clipboard

### 9. Gitent Module

Agent-centric version control tracking:

- **gitent_init** - Initialize or connect to tracking session
- **gitent_status** - View session and uncommitted changes
- **gitent_track** - Manually track file changes (create/modify/delete/rename)
- **gitent_commit** - Commit tracked changes with message
- **gitent_log** - View commit history
- **gitent_diff** - View differences in unified or structured format
- **gitent_rollback** - Rollback to previous commit (preview mode by default)

Track file changes, create commits, view history, and rollback operations during AI agent operations.

### 10. Clipboard Module

Session-based copy/paste with tagging to save tokens:

- **clip_copy_file** - Copy text from a file (with optional line ranges) into session clipboard with a tag
- **clip_copy** - Copy arbitrary text directly into session clipboard with a tag
- **clip_paste_file** - Paste tagged content into a file (overwrite/append/prepend/line-replace)
- **clip_paste** - Retrieve tagged content or list all stored entries with metadata
- **clip_clear** - Clear one or all clipboard entries

### 11. Transform Module

Text and data processing utilities:

- **transform_diff** - Compare two texts or files with unified/inline/stats output
- **transform_encode** - Encode/decode base64, URL, hex, HTML entities
- **transform_hash** - Cryptographic hashing (SHA256, SHA512, MD5, BLAKE3) for text or files
- **transform_regex** - Regex operations: match, find_all, replace, split, extract capture groups
- **transform_json** - JSON manipulation: pretty-print, minify, validate, query, merge, keys, flatten
- **transform_text** - Text transforms: case conversion, sort/reverse/unique/trim/number lines, wrap, truncate, stats
- **transform_archive** - Create, extract, and list zip and tar.gz archives

## Installation

```bash
cargo add poly-mcp
```

## Usage

Poly MCP supports two transport modes: **stdio** (default) and **HTTP server**.

### Stdio Mode (Default)

Run the server using stdin/stdout (original MCP behavior):

```bash
poly-mcp
```

The server communicates via JSON-RPC 2.0 over stdin/stdout following the MCP protocol. This is useful for piping commands or integrating with tools that expect stdio communication.

**Example:**
```bash
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | poly-mcp
```

### HTTP Server Mode

Run as an HTTP server on a specific port:

```bash
poly-mcp --server --port 3000
```

**Options:**
- `--server` or `-s` - Enable HTTP server mode
- `--port <PORT>` or `-p <PORT>` - Port to bind to (default: 3000)
- `--host <HOST>` - Host to bind to (default: 127.0.0.1)

**Example usage:**
```bash
# Start server on default port 3000
poly-mcp --server

# Start server on custom port
poly-mcp --server --port 8080

# Start server on all interfaces
poly-mcp --server --host 0.0.0.0 --port 3000
```

**HTTP Endpoints:**
- `POST /` or `POST /jsonrpc` - JSON-RPC 2.0 endpoint
- `GET /health` - Health check endpoint

**Example HTTP request:**
```bash
curl -X POST http://localhost:3000/jsonrpc \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
      "name": "fs_read",
      "arguments": {"path": "/etc/hosts"}
    }
  }'
```

**Health check:**
```bash
curl http://localhost:3000/health
```

### MCP Protocol Messages

**Initialize:**
```json
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}
```

**List Tools:**
```json
{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}
```

**Call Tool:**
```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "fs_read",
    "arguments": {
      "path": "/path/to/file.txt"
    }
  }
}
```

## Example Tool Calls

### Read a File
```json
{
  "name": "fs_read",
  "arguments": {"path": "/etc/hosts"}
}
```

### Read Specific Line Ranges
```json
{
  "name": "fs_read",
  "arguments": {
    "path": "/var/log/app.log",
    "lines": [[1, 10], [50, 60]]
  }
}
```

### Write to Specific Line Ranges
```json
{
  "name": "fs_write",
  "arguments": {
    "path": "/tmp/config.txt",
    "content": "# Header v2\nversion=2.0",
    "lines": [[1, 2]]
  }
}
```

### Create a Snapshot
```json
{
  "name": "fs_snapshot",
  "arguments": {
    "path": "/important/project",
    "max_snapshots": 5
  }
}
```

### Run Diagnostics
```json
{
  "name": "diagnostics_get",
  "arguments": {"path": "./src"}
}
```

### Execute Bash Script
```json
{
  "name": "silent_script",
  "arguments": {
    "script": "#!/bin/bash\necho 'Hello World'\nls -la",
    "timeout": 30
  }
}
```

### Monitor Resources
```json
{
  "name": "silent_resources",
  "arguments": {
    "detailed": true,
    "process_filter": "rust"
  }
}
```

### Fetch URL as Markdown
```json
{
  "name": "net_fetch",
  "arguments": {
    "url": "https://example.com",
    "convert_to_markdown": true
  }
}
```

### Get Latest Package Version
```json
{
  "name": "net_cargo",
  "arguments": {
    "crate_name": "tokio",
    "action": "latest"
  }
}
```

### Count Tokens
```json
{
  "name": "ctx_token_count",
  "arguments": {
    "text": "Your text here",
    "model": "gpt-4"
  }
}
```

### Estimate API Cost
```json
{
  "name": "ctx_estimate_cost",
  "arguments": {
    "provider": "anthropic",
    "model": "claude-3-opus",
    "input_tokens": 1000,
    "output_tokens": 500
  }
}
```

### Git Operations
```json
{
  "name": "git_status",
  "arguments": {"path": "."}
}
```

```json
{
  "name": "git_commit",
  "arguments": {
    "message": "feat: add new feature",
    "author_name": "Developer",
    "author_email": "dev@example.com"
  }
}
```

### Send Notification
```json
{
  "name": "input_notify",
  "arguments": {
    "title": "Build Complete",
    "message": "Your project has been built successfully!",
    "type": "both",
    "urgency": "normal"
  }
}
```

### Clipboard Operations
```json
{
  "name": "input_clipboard_write",
  "arguments": {"content": "Hello from Poly MCP!"}
}
```

### Gitent Operations
```json
{
  "name": "gitent_init",
  "arguments": {"path": "./my-project"}
}
```

```json
{
  "name": "gitent_track",
  "arguments": {
    "path": "src/main.rs",
    "change_type": "modify",
    "content": "fn main() { println!(\"Updated\"); }",
    "agent_id": "claude"
  }
}
```

```json
{
  "name": "gitent_commit",
  "arguments": {
    "message": "Updated main function",
    "agent_id": "claude"
  }
}
```

```json
{
  "name": "gitent_log",
  "arguments": {"limit": 10, "verbose": true}
}
```

```json
{
  "name": "gitent_rollback",
  "arguments": {
    "commit_id": "abc123...",
    "execute": false
  }
}
```

## License

Licensed under the MIT License.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.