@agent2pdf/mcp-server 1.0.0

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 ADDED
@@ -0,0 +1,209 @@
1
+ # @agent2pdf/mcp-server
2
+
3
+ Official MCP (Model Context Protocol) Server for Agent2PDF with auto-polling support.
4
+
5
+ This MCP Server acts as a bridge between MCP clients (like Claude Desktop, Cursor) and the Agent2PDF async job API. It automatically handles job creation, polling, and returns a direct download URL when the PDF is ready, providing a "pseudo-synchronous" experience.
6
+
7
+ ## Features
8
+
9
+ - 🚀 **Auto-polling**: Automatically polls job status until completion
10
+ - 📦 **Zero-config**: Works out of the box with `npx`
11
+ - 🔄 **Three tools**: `generate_pdf`, `list_available_templates`, `get_job_status`
12
+ - ⚡ **Fast**: Typical wait time: 5-30 seconds
13
+
14
+ ## Installation
15
+
16
+ ### Using npx (Recommended)
17
+
18
+ No installation needed! Use directly with `npx`:
19
+
20
+ ```bash
21
+ npx @agent2pdf/mcp-server
22
+ ```
23
+
24
+ ### Local Installation
25
+
26
+ ```bash
27
+ npm install -g @agent2pdf/mcp-server
28
+ ```
29
+
30
+ ## Configuration
31
+
32
+ ### Claude Desktop
33
+
34
+ Add to your Claude Desktop config file (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "agent2pdf": {
40
+ "command": "npx",
41
+ "args": ["@agent2pdf/mcp-server"],
42
+ "env": {
43
+ "AGENT2PDF_API_KEY": "your-api-key-here"
44
+ }
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ Or if installed globally:
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "agent2pdf": {
56
+ "command": "agent2pdf-mcp",
57
+ "env": {
58
+ "AGENT2PDF_API_KEY": "your-api-key-here"
59
+ }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### Cursor
66
+
67
+ Add to your Cursor settings (`.cursor/mcp.json` or similar):
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "agent2pdf": {
73
+ "command": "npx",
74
+ "args": ["@agent2pdf/mcp-server"],
75
+ "env": {
76
+ "AGENT2PDF_API_KEY": "your-api-key-here"
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Getting Your API Key
84
+
85
+ 1. Sign in to [Agent2PDF Dashboard](https://agent2pdf.com)
86
+ 2. Go to **Settings → API Keys**
87
+ 3. Create a new API key
88
+ 4. Copy the key and add it to your MCP configuration
89
+
90
+ ## Available Tools
91
+
92
+ ### `generate_pdf`
93
+
94
+ Generate a PDF from Markdown content. This tool automatically handles the async job process and returns a download URL when ready.
95
+
96
+ **Arguments:**
97
+ - `markdown` (required): The document body in Markdown format
98
+ - `template_type` (optional): Template type (`general`, `tech_spec`, `invoice`, `report`, `resume`, `letter`, `meeting`). Defaults to `general`
99
+ - `title` (optional): Document title. Defaults to "Untitled"
100
+ - `author` (optional): Author or company name
101
+ - `template_id` (optional): Custom template ID if using a saved template
102
+
103
+ **Example:**
104
+ ```
105
+ Generate a PDF with markdown "# Hello\n\nWorld", title "Test Document", template_type "general"
106
+ ```
107
+
108
+ ### `list_available_templates`
109
+
110
+ Get a list of available built-in PDF templates with descriptions and recommended use cases.
111
+
112
+ **Arguments:** None
113
+
114
+ **Example:**
115
+ ```
116
+ List available templates
117
+ ```
118
+
119
+ ### `get_job_status`
120
+
121
+ Check the status of an async PDF job. Useful for manual polling.
122
+
123
+ **Arguments:**
124
+ - `job_id` (required): The job ID returned by `generate_pdf` or `POST /api/v1/jobs`
125
+
126
+ **Example:**
127
+ ```
128
+ Check job status for job_id "abc123"
129
+ ```
130
+
131
+ ## How It Works
132
+
133
+ 1. **Job Creation**: When `generate_pdf` is called, the server creates an async job via `POST /api/v1/jobs`
134
+ 2. **Auto-polling**: The server polls `GET /api/v1/jobs/{job_id}` every 3 seconds
135
+ 3. **Completion**: When the job status is `completed`, it returns the download URL
136
+ 4. **Error Handling**: If the job fails or times out, it returns an error message
137
+
138
+ ## Development
139
+
140
+ ### Prerequisites
141
+
142
+ - Node.js >= 18
143
+ - pnpm (recommended) or npm
144
+
145
+ ### Setup
146
+
147
+ ```bash
148
+ # Install dependencies
149
+ pnpm install
150
+
151
+ # Build
152
+ pnpm build
153
+
154
+ # Development mode (watch)
155
+ pnpm dev
156
+ ```
157
+
158
+ ### Local Testing
159
+
160
+ #### 自動化測試腳本
161
+
162
+ 使用內建的測試腳本快速驗證所有功能:
163
+
164
+ ```bash
165
+ # 設定 API Key
166
+ export AGENT2PDF_API_KEY="your-api-key"
167
+
168
+ # 執行測試
169
+ npm test
170
+
171
+ # 或直接執行
172
+ node test-mcp-server.js
173
+ ```
174
+
175
+ 測試腳本會自動測試:
176
+ - ✅ 環境變數檢查
177
+ - ✅ 列出可用模板
178
+ - ✅ 建立 PDF Job
179
+ - ✅ 輪詢 Job 狀態直到完成
180
+ - ✅ MCP Server 基本連線
181
+
182
+ #### 手動測試
183
+
184
+ ```bash
185
+ # Link globally for testing
186
+ pnpm link --global
187
+
188
+ # Then use in Claude Desktop config
189
+ {
190
+ "mcpServers": {
191
+ "agent2pdf": {
192
+ "command": "agent2pdf-mcp",
193
+ "env": {
194
+ "AGENT2PDF_API_KEY": "your-test-key"
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ ## License
202
+
203
+ MIT
204
+
205
+ ## Support
206
+
207
+ - Documentation: [https://agent2pdf.com/docs](https://agent2pdf.com/docs)
208
+ - API Reference: [https://agent2pdf.com/docs/api](https://agent2pdf.com/docs/api)
209
+ - Issues: [GitHub Issues](https://github.com/AustinChou/agent2pdf/issues)
@@ -0,0 +1,2 @@
1
+
2
+ export { }