Skip to content

Commit 13f3b4f

Browse files
committed
docs: comprehensive documentation update
- Add TOON output format documentation - Add response truncation and raw logs section - Add debugging and testing instructions - Enhance JMESPath filtering examples - Add Technical Details section with architecture - Expand CLI commands documentation - Update version to v3.2.1
1 parent 2cd13d6 commit 13f3b4f

1 file changed

Lines changed: 285 additions & 12 deletions

File tree

README.md

Lines changed: 285 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,23 @@ export ATLASSIAN_SITE_NAME="your-company" # for your-company.atlassian.net
4141
export ATLASSIAN_USER_EMAIL="your.email@company.com"
4242
export ATLASSIAN_API_TOKEN="your_api_token"
4343

44-
# List your Confluence spaces
44+
# List your Confluence spaces (TOON format by default)
4545
npx -y @aashari/mcp-server-atlassian-confluence get --path "/wiki/api/v2/spaces"
4646

47-
# Get details about a specific space
48-
npx -y @aashari/mcp-server-atlassian-confluence get --path "/wiki/api/v2/spaces/123456"
47+
# Get details about a specific space with field filtering
48+
npx -y @aashari/mcp-server-atlassian-confluence get \
49+
--path "/wiki/api/v2/spaces/123456" \
50+
--jq "{id: id, key: key, name: name, type: type}"
4951

5052
# Get a page with JMESPath filtering
51-
npx -y @aashari/mcp-server-atlassian-confluence get --path "/wiki/api/v2/pages/789" --jq "{id: id, title: title, status: status}"
53+
npx -y @aashari/mcp-server-atlassian-confluence get \
54+
--path "/wiki/api/v2/pages/789" \
55+
--jq "{id: id, title: title, status: status}"
56+
57+
# Search for pages (using CQL)
58+
npx -y @aashari/mcp-server-atlassian-confluence get \
59+
--path "/wiki/rest/api/search" \
60+
--query-params '{"cql": "type=page AND space=DEV"}'
5261
```
5362

5463
## Connect to AI Assistants
@@ -77,13 +86,13 @@ Restart Claude Desktop, and you'll see the confluence server in the status bar.
7786

7887
### For Other AI Assistants
7988

80-
Most AI assistants support MCP. Install the server globally:
89+
Most AI assistants support MCP (Cursor AI, Continue.dev, and others). Install the server globally:
8190

8291
```bash
8392
npm install -g @aashari/mcp-server-atlassian-confluence
8493
```
8594

86-
Then configure your AI assistant to use the MCP server with STDIO transport.
95+
Then configure your AI assistant to use the MCP server with STDIO transport. The binary is available as `mcp-atlassian-confluence` after global installation.
8796

8897
### Alternative: Configuration File
8998

@@ -103,6 +112,25 @@ Create `~/.mcp/configs.json` for system-wide configuration:
103112

104113
**Alternative config keys:** The system also accepts `"atlassian-confluence"`, `"@aashari/mcp-server-atlassian-confluence"`, or `"mcp-server-atlassian-confluence"` instead of `"confluence"`.
105114

115+
### Using Environment Variables
116+
117+
You can also configure credentials using environment variables or a `.env` file:
118+
119+
```bash
120+
# Create a .env file in your project directory
121+
cat > .env << EOF
122+
ATLASSIAN_SITE_NAME=your-company
123+
ATLASSIAN_USER_EMAIL=your.email@company.com
124+
ATLASSIAN_API_TOKEN=your_api_token
125+
DEBUG=false
126+
EOF
127+
```
128+
129+
The server will automatically load these values from:
130+
1. Environment variables
131+
2. `.env` file in the current directory
132+
3. `~/.mcp/configs.json` (as shown above)
133+
106134
## Available Tools
107135

108136
This MCP server provides 5 generic tools that can access any Confluence API endpoint:
@@ -112,8 +140,21 @@ This MCP server provides 5 generic tools that can access any Confluence API endp
112140
| `conf_get` | GET any Confluence API endpoint (read data) |
113141
| `conf_post` | POST to any endpoint (create resources) |
114142
| `conf_put` | PUT to any endpoint (replace resources) |
115-
| `conf_patch` | PATCH any endpoint (partial updates) |
116-
| `conf_delete` | DELETE any endpoint (remove resources) |
143+
| `conf_patch` | PATCH to any endpoint (partial updates) |
144+
| `conf_delete` | DELETE from any endpoint (remove resources) |
145+
146+
### Tool Parameters
147+
148+
All tools share these common parameters:
149+
150+
- **`path`** (required): The API endpoint path (e.g., `/wiki/api/v2/spaces`)
151+
- **`queryParams`** (optional): Query parameters as key-value pairs (e.g., `{"limit": "25", "space-id": "123"}`)
152+
- **`jq`** (optional): JMESPath expression to filter/transform the response (e.g., `results[*].{id: id, title: title}`)
153+
- **`outputFormat`** (optional): Output format - `"toon"` (default, 30-60% fewer tokens) or `"json"`
154+
155+
Tools that accept a request body (`conf_post`, `conf_put`, `conf_patch`):
156+
157+
- **`body`** (required): Request body as a JSON object
117158

118159
### Common API Paths
119160

@@ -140,9 +181,37 @@ This MCP server provides 5 generic tools that can access any Confluence API endp
140181
**Search:**
141182
- `/wiki/rest/api/search` - Search content (use `cql` query param)
142183

184+
### TOON Output Format
185+
186+
**What is TOON?** TOON (Token-Oriented Object Notation) is a format optimized for LLM token efficiency, reducing token costs by 30-60% compared to JSON. It's the default output format for all tools.
187+
188+
**Benefits:**
189+
- Tabular arrays use fewer tokens than JSON arrays
190+
- Minimal syntax overhead (no quotes, brackets, commas where unnecessary)
191+
- Still human-readable and parseable
192+
193+
**When to use JSON instead:**
194+
- When you need standard JSON for other tools
195+
- When debugging or manual inspection is needed
196+
197+
**Example comparison:**
198+
```json
199+
// JSON format (verbose)
200+
{"results": [{"id": "123", "title": "My Page"}, {"id": "456", "title": "Other Page"}]}
201+
202+
// TOON format (efficient)
203+
results:
204+
- id: 123
205+
title: My Page
206+
- id: 456
207+
title: Other Page
208+
```
209+
210+
To use JSON instead of TOON, set `outputFormat: "json"` in your request.
211+
143212
### JMESPath Filtering
144213

145-
All tools support optional JMESPath (`jq`) filtering to extract specific data:
214+
All tools support optional JMESPath (`jq`) filtering to extract specific data and reduce token costs:
146215

147216
```bash
148217
# Get just space names and keys
@@ -156,6 +225,17 @@ npx -y @aashari/mcp-server-atlassian-confluence get \
156225
--jq "{id: id, title: title, status: status}"
157226
```
158227

228+
**IMPORTANT:** Always use the `jq` parameter to filter responses to only the fields you need. Unfiltered responses can be very large and expensive in token costs.
229+
230+
**JMESPath Syntax Reference:**
231+
- Official docs: [jmespath.org](https://jmespath.org)
232+
- Common patterns:
233+
- `results[*]` - All items in results array
234+
- `results[0]` - First item only
235+
- `results[*].id` - Just IDs from all items
236+
- `results[*].{id: id, title: title}` - Create objects with selected fields
237+
- `results[?status=='current']` - Filter by condition
238+
159239
## Real-World Examples
160240

161241
### Explore Your Knowledge Base
@@ -191,16 +271,43 @@ Ask your AI assistant:
191271

192272
## CLI Commands
193273

194-
The CLI mirrors the MCP tools for direct terminal access:
274+
The CLI mirrors the MCP tools for direct terminal access. All commands support the same parameters as the tools.
275+
276+
### Available Commands
277+
278+
- `get` - GET any Confluence endpoint
279+
- `post` - POST to any endpoint
280+
- `put` - PUT to any endpoint
281+
- `patch` - PATCH any endpoint
282+
- `delete` - DELETE from any endpoint
283+
284+
### CLI Parameters
285+
286+
**All commands:**
287+
- `-p, --path <path>` (required) - API endpoint path
288+
- `-q, --query-params <json>` (optional) - Query parameters as JSON
289+
- `--jq <expression>` (optional) - JMESPath filter expression
290+
- `-o, --output-format <format>` (optional) - Output format: `toon` (default) or `json`
291+
292+
**Commands with body (post, put, patch):**
293+
- `-b, --body <json>` (required) - Request body as JSON
294+
295+
### Examples
195296

196297
```bash
197298
# GET request
198299
npx -y @aashari/mcp-server-atlassian-confluence get --path "/wiki/api/v2/spaces"
199300

200-
# GET with query parameters
301+
# GET with query parameters and JMESPath filter
201302
npx -y @aashari/mcp-server-atlassian-confluence get \
202303
--path "/wiki/api/v2/pages" \
203-
--query-params '{"space-id": "123456", "limit": "10"}'
304+
--query-params '{"space-id": "123456", "limit": "10"}' \
305+
--jq "results[*].{id: id, title: title}"
306+
307+
# GET with JSON output format
308+
npx -y @aashari/mcp-server-atlassian-confluence get \
309+
--path "/wiki/api/v2/spaces" \
310+
--output-format json
204311

205312
# POST request (create a page)
206313
npx -y @aashari/mcp-server-atlassian-confluence post \
@@ -217,11 +324,130 @@ npx -y @aashari/mcp-server-atlassian-confluence put \
217324
--path "/wiki/api/v2/pages/789" \
218325
--body '{"id": "789", "status": "current", "title": "Updated Title", "spaceId": "123456", "body": {"representation": "storage", "value": "<p>Updated content</p>"}, "version": {"number": 2}}'
219326

327+
# PATCH request (partial update)
328+
npx -y @aashari/mcp-server-atlassian-confluence patch \
329+
--path "/wiki/api/v2/spaces/123456" \
330+
--body '{"name": "New Space Name"}'
331+
220332
# DELETE request
221333
npx -y @aashari/mcp-server-atlassian-confluence delete \
222334
--path "/wiki/api/v2/pages/789"
223335
```
224336

337+
## Response Handling
338+
339+
### Large Response Truncation
340+
341+
When API responses exceed approximately 40,000 characters (~10,000 tokens), the server automatically truncates the response to stay within token limits. When this happens:
342+
343+
1. **You'll see a truncation notice** at the end of the response showing:
344+
- How much of the original response is shown
345+
- The original response size
346+
- Guidance on accessing the full data
347+
348+
2. **The full raw response is saved** to a temporary file in `/tmp/mcp/` (path provided in the truncation notice)
349+
350+
3. **Best practices to avoid truncation:**
351+
- **Always use the `jq` parameter** to filter responses to only needed fields
352+
- Use `limit` query parameter to restrict result counts (e.g., `{"limit": "5"}`)
353+
- Request specific resources by ID rather than listing all
354+
- Use targeted CQL queries for searches
355+
356+
**Example of efficient filtering:**
357+
```bash
358+
# Instead of getting all space data (can be huge):
359+
npx -y @aashari/mcp-server-atlassian-confluence get \
360+
--path "/wiki/api/v2/spaces"
361+
362+
# Get only the fields you need:
363+
npx -y @aashari/mcp-server-atlassian-confluence get \
364+
--path "/wiki/api/v2/spaces" \
365+
--query-params '{"limit": "10"}' \
366+
--jq "results[*].{id: id, key: key, name: name}"
367+
```
368+
369+
### Debug Logging
370+
371+
Enable debug logging to see detailed request/response information:
372+
373+
```bash
374+
# Set DEBUG environment variable
375+
export DEBUG=true
376+
377+
# For MCP mode
378+
DEBUG=true npx -y @aashari/mcp-server-atlassian-confluence
379+
380+
# For CLI mode
381+
DEBUG=true npx -y @aashari/mcp-server-atlassian-confluence get --path "/wiki/api/v2/spaces"
382+
```
383+
384+
Debug logs are written to: `~/.mcp/data/@aashari-mcp-server-atlassian-confluence.[session-id].log`
385+
386+
## Testing & Development
387+
388+
### Using MCP Inspector
389+
390+
The MCP Inspector provides a visual interface for testing tools:
391+
392+
```bash
393+
# Install the server globally
394+
npm install -g @aashari/mcp-server-atlassian-confluence
395+
396+
# Run with MCP Inspector
397+
npx @modelcontextprotocol/inspector node $(which mcp-atlassian-confluence)
398+
```
399+
400+
Or use the built-in development command if you've cloned the repository:
401+
402+
```bash
403+
npm run mcp:inspect
404+
```
405+
406+
This starts the server in HTTP mode and opens the inspector UI in your browser.
407+
408+
### HTTP Mode for Testing
409+
410+
You can run the server in HTTP mode to test with curl or other HTTP clients:
411+
412+
```bash
413+
# Start server in HTTP mode
414+
TRANSPORT_MODE=http npx -y @aashari/mcp-server-atlassian-confluence
415+
```
416+
417+
The server will listen on `http://localhost:3000/mcp` by default. You can change the port:
418+
419+
```bash
420+
PORT=8080 TRANSPORT_MODE=http npx -y @aashari/mcp-server-atlassian-confluence
421+
```
422+
423+
**Testing with curl:**
424+
425+
```bash
426+
# Initialize session
427+
curl -X POST http://localhost:3000/mcp \
428+
-H "Content-Type: application/json" \
429+
-H "Accept: application/json, text/event-stream" \
430+
-d '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "clientInfo": {"name": "curl-test", "version": "1.0.0"}, "capabilities": {}}}'
431+
432+
# List available tools
433+
curl -X POST http://localhost:3000/mcp \
434+
-H "Content-Type: application/json" \
435+
-H "Accept: application/json, text/event-stream" \
436+
-d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}'
437+
438+
# Call a tool
439+
curl -X POST http://localhost:3000/mcp \
440+
-H "Content-Type: application/json" \
441+
-H "Accept: application/json, text/event-stream" \
442+
-d '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "conf_get", "arguments": {"path": "/wiki/api/v2/spaces", "queryParams": {"limit": "5"}}}}'
443+
```
444+
445+
The response comes as Server-Sent Events (SSE) with format:
446+
```
447+
event: message
448+
data: {"jsonrpc": "2.0", "id": 1, "result": {...}}
449+
```
450+
225451
## Troubleshooting
226452

227453
### "Authentication failed" or "403 Forbidden"
@@ -339,6 +565,53 @@ conf_get, conf_post, conf_put, conf_patch, conf_delete
339565
- `conf_search` -> `conf_get` with path `/wiki/rest/api/search?cql=...`
340566
- `conf_add_comment` -> `conf_post` with path `/wiki/api/v2/pages/{id}/footer-comments`
341567

568+
## Technical Details
569+
570+
### Requirements
571+
572+
- **Node.js**: 18.0.0 or higher
573+
- **MCP SDK**: 1.23.0 (uses modern `registerTool` API)
574+
- **Confluence**: Cloud only (Server/Data Center not supported)
575+
576+
### Architecture
577+
578+
This server follows a 5-layer architecture:
579+
580+
1. **Tools Layer** (`src/tools/`) - MCP tool definitions with Zod validation
581+
2. **CLI Layer** (`src/cli/`) - Commander-based CLI for direct testing
582+
3. **Controllers Layer** (`src/controllers/`) - Business logic, JMESPath filtering, output formatting
583+
4. **Services Layer** (`src/services/`) - Confluence API communication
584+
5. **Utils Layer** (`src/utils/`) - Shared utilities (logger, config, formatters, TOON encoder)
585+
586+
### Features
587+
588+
- **Generic HTTP method tools** - Access any Confluence API endpoint
589+
- **TOON output format** - 30-60% token reduction vs JSON
590+
- **JMESPath filtering** - Extract only needed data
591+
- **Response truncation** - Automatic handling of large responses
592+
- **Raw response logging** - Full responses saved to `/tmp/mcp/`
593+
- **Dual transport** - STDIO (for Claude Desktop) and HTTP (for web integrations)
594+
- **Debug logging** - Comprehensive logging for troubleshooting
595+
596+
### Version History
597+
598+
**v3.2.1** (Current)
599+
- Add raw response logging with truncation for large API responses
600+
- Improve dependency compatibility
601+
602+
**v3.2.0**
603+
- Modernize MCP SDK to v1.23.0 with registerTool API
604+
605+
**v3.1.0**
606+
- Add TOON output format for token-efficient LLM responses
607+
608+
**v3.0.0** (Breaking change)
609+
- Replace 8+ domain-specific tools with 5 generic HTTP method tools
610+
- Add JMESPath filtering support
611+
- Full Confluence API access via generic methods
612+
613+
See [CHANGELOG.md](CHANGELOG.md) for complete version history.
614+
342615
## Support
343616

344617
Need help? Here's how to get assistance:

0 commit comments

Comments
 (0)