@satiyap/confluence-reader-mcp 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/confluence/client.js +4 -4
- package/dist/index.js +14 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,8 +36,10 @@ Reload your shell or open a new terminal.
|
|
|
36
36
|
|----------|----------|-------------|
|
|
37
37
|
| `CONFLUENCE_TOKEN` | Yes | Scoped API token |
|
|
38
38
|
| `CONFLUENCE_EMAIL` | Yes | Email tied to your Atlassian account |
|
|
39
|
-
| `CONFLUENCE_CLOUD_ID` |
|
|
40
|
-
| `CONFLUENCE_BASE_URL` |
|
|
39
|
+
| `CONFLUENCE_CLOUD_ID` | Yes* | Cloud ID — routes via `api.atlassian.com` |
|
|
40
|
+
| `CONFLUENCE_BASE_URL` | Yes* | Direct tenant URL, e.g. `https://your-org.atlassian.net` |
|
|
41
|
+
|
|
42
|
+
*One of `CONFLUENCE_CLOUD_ID` or `CONFLUENCE_BASE_URL` is required. `CONFLUENCE_CLOUD_ID` is recommended.
|
|
41
43
|
|
|
42
44
|
### 3. Add to MCP Config
|
|
43
45
|
|
|
@@ -74,12 +76,13 @@ Lists the direct child pages of a Confluence page without fetching their content
|
|
|
74
76
|
|
|
75
77
|
### `confluence.fetch_image`
|
|
76
78
|
|
|
77
|
-
Downloads an image attachment from a Confluence page by filename
|
|
79
|
+
Downloads an image attachment from a Confluence page by filename and saves it to a local directory.
|
|
78
80
|
|
|
79
81
|
| Parameter | Type | Description |
|
|
80
82
|
|-----------|------|-------------|
|
|
81
83
|
| `url` | string | Confluence page URL |
|
|
82
84
|
| `filename` | string | Attachment filename (e.g. `architecture.png`) |
|
|
85
|
+
| `destination` | string | Local directory path to save the image to |
|
|
83
86
|
|
|
84
87
|
### `confluence.compare`
|
|
85
88
|
|
|
@@ -123,12 +123,12 @@ export async function fetchAttachments(cfg, pageId) {
|
|
|
123
123
|
return all;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* Download an attachment binary
|
|
127
|
-
*
|
|
126
|
+
* Download an attachment binary from a Confluence page.
|
|
127
|
+
* Uses the v1 REST API download endpoint which works with scoped tokens.
|
|
128
128
|
*/
|
|
129
|
-
export async function downloadAttachment(cfg,
|
|
129
|
+
export async function downloadAttachment(cfg, pageId, attachmentId) {
|
|
130
130
|
const base = buildBase(cfg);
|
|
131
|
-
const url = `${base}/wiki
|
|
131
|
+
const url = `${base}/wiki/rest/api/content/${pageId}/child/attachment/${attachmentId}/download`;
|
|
132
132
|
const res = await fetch(url, {
|
|
133
133
|
method: "GET",
|
|
134
134
|
headers: buildAuthHeaders(cfg),
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { storageToMarkdown } from "./confluence/transform.js";
|
|
|
8
8
|
import { generateUnifiedDiff, generateDiffStats } from "./compare/diff.js";
|
|
9
9
|
const server = new McpServer({
|
|
10
10
|
name: "confluence-reader-mcp",
|
|
11
|
-
version: "0.2.
|
|
11
|
+
version: "0.2.2"
|
|
12
12
|
});
|
|
13
13
|
function getEnv(name) {
|
|
14
14
|
const v = process.env[name];
|
|
@@ -34,7 +34,7 @@ function validateEnvironment() {
|
|
|
34
34
|
errors.forEach(err => console.error(` • ${err}`));
|
|
35
35
|
console.error("\nSet the required environment variables in your shell profile (~/.zshrc, ~/.bashrc, etc.):\n");
|
|
36
36
|
console.error(" export CONFLUENCE_TOKEN=\"your_scoped_token\"");
|
|
37
|
-
console.error(" export CONFLUENCE_EMAIL=\"
|
|
37
|
+
console.error(" export CONFLUENCE_EMAIL=\"your_email@example.com\"");
|
|
38
38
|
console.error(" export CONFLUENCE_CLOUD_ID=\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\n");
|
|
39
39
|
process.exit(1);
|
|
40
40
|
}
|
|
@@ -79,10 +79,11 @@ server.tool("confluence.list_children", "List the direct child pages of a Conflu
|
|
|
79
79
|
: "No child pages found.";
|
|
80
80
|
return { content: [{ type: "text", text }] };
|
|
81
81
|
});
|
|
82
|
-
server.tool("confluence.fetch_image", "Download an image attachment from a Confluence page by filename. Returns the
|
|
82
|
+
server.tool("confluence.fetch_image", "Download an image attachment from a Confluence page by filename and save it to a local directory. Returns the saved file path.", {
|
|
83
83
|
url: z.string().describe("Confluence page URL"),
|
|
84
|
-
filename: z.string().describe("Attachment filename (e.g. 'architecture.png')")
|
|
85
|
-
|
|
84
|
+
filename: z.string().describe("Attachment filename (e.g. 'architecture.png')"),
|
|
85
|
+
destination: z.string().describe("Local directory path to save the image to")
|
|
86
|
+
}, async ({ url, filename, destination }) => {
|
|
86
87
|
const cfg = getCfg();
|
|
87
88
|
const pageId = extractConfluencePageId(url);
|
|
88
89
|
const attachments = await fetchAttachments(cfg, pageId);
|
|
@@ -96,32 +97,17 @@ server.tool("confluence.fetch_image", "Download an image attachment from a Confl
|
|
|
96
97
|
}]
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const { buffer, contentType } = await downloadAttachment(cfg, downloadLink);
|
|
109
|
-
const base64 = buffer.toString("base64");
|
|
110
|
-
// Return as base64 image content
|
|
111
|
-
if (contentType.startsWith("image/")) {
|
|
112
|
-
return {
|
|
113
|
-
content: [{
|
|
114
|
-
type: "image",
|
|
115
|
-
data: base64,
|
|
116
|
-
mimeType: contentType,
|
|
117
|
-
}]
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// Non-image attachment — return as base64 text
|
|
100
|
+
const { buffer } = await downloadAttachment(cfg, pageId, match.id);
|
|
101
|
+
// Ensure destination directory exists
|
|
102
|
+
const fs = await import("node:fs/promises");
|
|
103
|
+
const path = await import("node:path");
|
|
104
|
+
await fs.mkdir(destination, { recursive: true });
|
|
105
|
+
const filePath = path.join(destination, match.title);
|
|
106
|
+
await fs.writeFile(filePath, buffer);
|
|
121
107
|
return {
|
|
122
108
|
content: [{
|
|
123
109
|
type: "text",
|
|
124
|
-
text: `
|
|
110
|
+
text: `Saved "${match.title}" (${buffer.length} bytes) to ${filePath}`
|
|
125
111
|
}]
|
|
126
112
|
};
|
|
127
113
|
});
|