renderform-mcp 0.1.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/LICENSE +190 -0
- package/README.md +98 -0
- package/build/api.js +37 -0
- package/build/functions.js +162 -0
- package/build/index.js +38 -0
- package/build/parameters.js +81 -0
- package/build/prompts.js +59 -0
- package/build/toolkit.js +27 -0
- package/build/tools.js +100 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 SimpleLocalize
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# MCP Server for RenderForm
|
|
2
|
+
|
|
3
|
+
[RenderForm](https://renderform.io) is an API for automatically generating images, PDFs, screenshots and videos from templates.
|
|
4
|
+
|
|
5
|
+
This is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that provides tools for interacting with the [RenderForm API](https://api.renderform.io/openapi/docs).
|
|
6
|
+
|
|
7
|
+
## Features (Tools)
|
|
8
|
+
|
|
9
|
+
- Render an image/PDF/video from a template
|
|
10
|
+
- Create a screenshot of a web page
|
|
11
|
+
- Convert a web page to PDF
|
|
12
|
+
- List render results
|
|
13
|
+
- Get render result details
|
|
14
|
+
- Delete a render result
|
|
15
|
+
- List templates
|
|
16
|
+
- Get template details
|
|
17
|
+
- Delete a template
|
|
18
|
+
- Get organization usage (credits, uploads, plan)
|
|
19
|
+
- List available fonts
|
|
20
|
+
|
|
21
|
+
Feel free to add more tools by making a pull request or creating a feature request.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
To use the MCP server, you'll need an API key. You can create and manage API keys in **RenderForm > Settings > API Keys**.
|
|
26
|
+
|
|
27
|
+
To run the server in a client like Claude Desktop, Cursor or Windsurf, add the following to your MCP config:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"servers": {
|
|
32
|
+
"renderform": {
|
|
33
|
+
"type": "stdio",
|
|
34
|
+
"command": "npx",
|
|
35
|
+
"args": ["-y", "renderform-mcp", "--api-key=RENDERFORM_API_KEY"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Replace `RENDERFORM_API_KEY` with your API key.
|
|
42
|
+
|
|
43
|
+
For detailed setup guides, see:
|
|
44
|
+
|
|
45
|
+
- [Cursor AI](https://docs.cursor.com/context/model-context-protocol)
|
|
46
|
+
- [Visual Studio Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers)
|
|
47
|
+
- [GitHub Copilot](https://github.blog/changelog/2025-05-19-agent-mode-and-mcp-support-for-copilot-in-jetbrains-eclipse-and-xcode-now-in-public-preview/)
|
|
48
|
+
- [Claude Desktop](https://modelcontextprotocol.io/quickstart/user)
|
|
49
|
+
- [Windsurf](https://docs.codeium.com/windsurf/mcp)
|
|
50
|
+
|
|
51
|
+
## Development
|
|
52
|
+
|
|
53
|
+
1. Install dependencies:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
2. Build the server:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm run build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
3. Update client to use the local build:
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"servers": {
|
|
69
|
+
"renderform": {
|
|
70
|
+
"command": "node",
|
|
71
|
+
"args": ["path/to/renderform-mcp/build/index.js"],
|
|
72
|
+
"env": {
|
|
73
|
+
"RENDERFORM_API_KEY": "your_api_key"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Debugging
|
|
81
|
+
|
|
82
|
+
To debug the MCP server, you can use the MCP Inspector tool:
|
|
83
|
+
|
|
84
|
+
1. Run the server with the inspector:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm run inspector
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. Open the provided URL in your browser to view and debug the MCP requests and responses.
|
|
91
|
+
|
|
92
|
+
3. Include the `--api-key` argument.
|
|
93
|
+
|
|
94
|
+
## Learn more
|
|
95
|
+
|
|
96
|
+
- [RenderForm developer docs](https://renderform.io/docs)
|
|
97
|
+
- [RenderForm API reference](https://api.renderform.io/openapi/docs)
|
|
98
|
+
- [Sign up for RenderForm](https://renderform.io)
|
package/build/api.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createPdf, createScreenshot, deleteRenderResult, deleteTemplate, getFonts, getRenderResult, getRenderResults, getTemplate, getTemplates, getUsage, renderImage, } from "./functions.js";
|
|
2
|
+
class RenderFormAPI {
|
|
3
|
+
apiKey;
|
|
4
|
+
constructor(apiKey) {
|
|
5
|
+
this.apiKey = apiKey;
|
|
6
|
+
}
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
async run(method, arg) {
|
|
9
|
+
switch (method) {
|
|
10
|
+
case "render_image":
|
|
11
|
+
return JSON.stringify(await renderImage(this.apiKey, arg));
|
|
12
|
+
case "create_screenshot":
|
|
13
|
+
return JSON.stringify(await createScreenshot(this.apiKey, arg));
|
|
14
|
+
case "create_pdf":
|
|
15
|
+
return JSON.stringify(await createPdf(this.apiKey, arg));
|
|
16
|
+
case "get_render_results":
|
|
17
|
+
return JSON.stringify(await getRenderResults(this.apiKey, arg));
|
|
18
|
+
case "get_render_result":
|
|
19
|
+
return JSON.stringify(await getRenderResult(this.apiKey, arg));
|
|
20
|
+
case "delete_render_result":
|
|
21
|
+
return JSON.stringify(await deleteRenderResult(this.apiKey, arg));
|
|
22
|
+
case "get_templates":
|
|
23
|
+
return JSON.stringify(await getTemplates(this.apiKey, arg));
|
|
24
|
+
case "get_template":
|
|
25
|
+
return JSON.stringify(await getTemplate(this.apiKey, arg));
|
|
26
|
+
case "delete_template":
|
|
27
|
+
return JSON.stringify(await deleteTemplate(this.apiKey, arg));
|
|
28
|
+
case "get_usage":
|
|
29
|
+
return JSON.stringify(await getUsage(this.apiKey));
|
|
30
|
+
case "get_fonts":
|
|
31
|
+
return JSON.stringify(await getFonts(this.apiKey));
|
|
32
|
+
default:
|
|
33
|
+
throw new Error("Invalid method " + method);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default RenderFormAPI;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
const BASE_URL = "https://api.renderform.io";
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
const handleError = (error) => {
|
|
5
|
+
if (axios.isAxiosError(error)) {
|
|
6
|
+
return error.response?.data ?? { msg: error.message, status: error.response?.status ?? 0 };
|
|
7
|
+
}
|
|
8
|
+
throw error;
|
|
9
|
+
};
|
|
10
|
+
export const renderImage = async (apiKey, params) => {
|
|
11
|
+
try {
|
|
12
|
+
const { output, ...body } = params;
|
|
13
|
+
const response = await axios.post(`${BASE_URL}/api/v2/render`, body, {
|
|
14
|
+
headers: {
|
|
15
|
+
"x-api-key": apiKey,
|
|
16
|
+
},
|
|
17
|
+
params: output ? { output } : undefined,
|
|
18
|
+
});
|
|
19
|
+
return response?.data;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return handleError(error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export const createScreenshot = async (apiKey, params) => {
|
|
26
|
+
try {
|
|
27
|
+
const response = await axios.post(`${BASE_URL}/api/v1/screenshots`, params, {
|
|
28
|
+
headers: {
|
|
29
|
+
"x-api-key": apiKey,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return response?.data;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return handleError(error);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const createPdf = async (apiKey, params) => {
|
|
39
|
+
try {
|
|
40
|
+
const response = await axios.post(`${BASE_URL}/api/v1/pdf`, params, {
|
|
41
|
+
headers: {
|
|
42
|
+
"x-api-key": apiKey,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return response?.data;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return handleError(error);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export const getRenderResults = async (apiKey, params) => {
|
|
52
|
+
try {
|
|
53
|
+
const { template, batch, page = 0, size = 20 } = params;
|
|
54
|
+
const response = await axios.get(`${BASE_URL}/api/v2/results`, {
|
|
55
|
+
headers: {
|
|
56
|
+
"x-api-key": apiKey,
|
|
57
|
+
},
|
|
58
|
+
params: { template, batch, page, size },
|
|
59
|
+
});
|
|
60
|
+
return response?.data;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return handleError(error);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
export const getRenderResult = async (apiKey, params) => {
|
|
67
|
+
try {
|
|
68
|
+
const { identifier } = params;
|
|
69
|
+
const response = await axios.get(`${BASE_URL}/api/v2/results/${encodeURIComponent(identifier)}`, {
|
|
70
|
+
headers: {
|
|
71
|
+
"x-api-key": apiKey,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
return response?.data;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return handleError(error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const deleteRenderResult = async (apiKey, params) => {
|
|
81
|
+
try {
|
|
82
|
+
const { identifier } = params;
|
|
83
|
+
const response = await axios.delete(`${BASE_URL}/api/v2/results/${encodeURIComponent(identifier)}`, {
|
|
84
|
+
headers: {
|
|
85
|
+
"x-api-key": apiKey,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
return response?.data;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return handleError(error);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
export const getTemplates = async (apiKey, params) => {
|
|
95
|
+
try {
|
|
96
|
+
const { name, tags, sourceTemplateId, page = 0, size = 20 } = params;
|
|
97
|
+
const response = await axios.get(`${BASE_URL}/api/v2/my-templates`, {
|
|
98
|
+
headers: {
|
|
99
|
+
"x-api-key": apiKey,
|
|
100
|
+
},
|
|
101
|
+
params: { name, tags, sourceTemplateId, page, size },
|
|
102
|
+
});
|
|
103
|
+
return response?.data;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return handleError(error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export const getTemplate = async (apiKey, params) => {
|
|
110
|
+
try {
|
|
111
|
+
const { templateId } = params;
|
|
112
|
+
const response = await axios.get(`${BASE_URL}/api/v2/my-templates/${encodeURIComponent(templateId)}`, {
|
|
113
|
+
headers: {
|
|
114
|
+
"x-api-key": apiKey,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
return response?.data;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return handleError(error);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export const deleteTemplate = async (apiKey, params) => {
|
|
124
|
+
try {
|
|
125
|
+
const { templateId } = params;
|
|
126
|
+
const response = await axios.delete(`${BASE_URL}/api/v2/my-templates/${encodeURIComponent(templateId)}`, {
|
|
127
|
+
headers: {
|
|
128
|
+
"x-api-key": apiKey,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return response?.data;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return handleError(error);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
export const getUsage = async (apiKey) => {
|
|
138
|
+
try {
|
|
139
|
+
const response = await axios.get(`${BASE_URL}/api/v1/usage`, {
|
|
140
|
+
headers: {
|
|
141
|
+
"x-api-key": apiKey,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
return response?.data;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return handleError(error);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
export const getFonts = async (apiKey) => {
|
|
151
|
+
try {
|
|
152
|
+
const response = await axios.get(`${BASE_URL}/api/v1/fonts`, {
|
|
153
|
+
headers: {
|
|
154
|
+
"x-api-key": apiKey,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
return response?.data;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return handleError(error);
|
|
161
|
+
}
|
|
162
|
+
};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import RenderFormMCPServer from "./toolkit.js";
|
|
4
|
+
const ACCEPTED_ARGS = ["api-key"];
|
|
5
|
+
function parseArgs(args) {
|
|
6
|
+
const options = {
|
|
7
|
+
apiKey: ""
|
|
8
|
+
};
|
|
9
|
+
args.forEach((arg) => {
|
|
10
|
+
if (arg.startsWith("--")) {
|
|
11
|
+
const [key, value] = arg.slice(2).split("=");
|
|
12
|
+
if (key == "api-key") {
|
|
13
|
+
options.apiKey = value;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
throw new Error(`Invalid argument: ${key}. Accepted arguments are: ${ACCEPTED_ARGS.join(", ")}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const apiKey = options.apiKey || process.env.RENDERFORM_API_KEY;
|
|
21
|
+
if (!apiKey) {
|
|
22
|
+
throw new Error("RenderForm API key not provided. Please pass it as an argument --api-key=$KEY or set the RENDERFORM_API_KEY environment variable.");
|
|
23
|
+
}
|
|
24
|
+
options.apiKey = apiKey;
|
|
25
|
+
return options;
|
|
26
|
+
}
|
|
27
|
+
async function main() {
|
|
28
|
+
const options = parseArgs(process.argv.slice(2));
|
|
29
|
+
const server = new RenderFormMCPServer({
|
|
30
|
+
apiKey: options.apiKey
|
|
31
|
+
});
|
|
32
|
+
const transport = new StdioServerTransport();
|
|
33
|
+
await server.connect(transport);
|
|
34
|
+
}
|
|
35
|
+
main().catch((error) => {
|
|
36
|
+
console.error("Fatal error in main():", error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const renderImageParameters = z.object({
|
|
3
|
+
template: z.string().min(1).describe("Template ID to render, e.g. template_1234."),
|
|
4
|
+
data: z
|
|
5
|
+
.record(z.any())
|
|
6
|
+
.optional()
|
|
7
|
+
.describe("Data to be merged into the template. Keys follow the 'componentId.property' convention, e.g. { 'my-text.text': 'John' }."),
|
|
8
|
+
fileName: z.string().optional().describe("Name of the file to be returned (without extension)."),
|
|
9
|
+
webhookUrl: z.string().optional().describe("Webhook URL to be called when the render is done."),
|
|
10
|
+
version: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("Cache key used for caching the rendered output. Reusing the same version returns the cached file."),
|
|
14
|
+
metadata: z.record(z.any()).optional().describe("Additional metadata to be passed to the webhook."),
|
|
15
|
+
batchName: z.string().optional().describe("Batch name used for grouping renders together."),
|
|
16
|
+
waitTime: z.number().min(0).max(5000).optional().describe("Wait time in milliseconds before rendering (max 5000)."),
|
|
17
|
+
output: z
|
|
18
|
+
.enum(["image", "json"])
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Output format. 'json' (default) returns a JSON object with the href of the rendered file, which is recommended here. 'image' returns raw image bytes and is not suitable for text responses."),
|
|
21
|
+
});
|
|
22
|
+
export const createScreenshotParameters = z.object({
|
|
23
|
+
url: z.string().min(1).describe("URL of the page to capture."),
|
|
24
|
+
width: z.number().min(32).max(5000).describe("Width of the screenshot in pixels (32-5000)."),
|
|
25
|
+
height: z.number().min(32).max(5000).describe("Height of the screenshot in pixels (32-5000)."),
|
|
26
|
+
waitTime: z
|
|
27
|
+
.number()
|
|
28
|
+
.min(0)
|
|
29
|
+
.max(5000)
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Wait time in milliseconds before capturing the screenshot (0-5000)."),
|
|
32
|
+
});
|
|
33
|
+
export const createPdfParameters = z.object({
|
|
34
|
+
url: z.string().min(1).describe("URL of the page to capture as a PDF."),
|
|
35
|
+
format: z
|
|
36
|
+
.enum(["A5", "A4", "A3", "LETTER", "LEGAL"])
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Output page format of the PDF. Defaults to A4."),
|
|
39
|
+
waitTime: z
|
|
40
|
+
.number()
|
|
41
|
+
.min(0)
|
|
42
|
+
.max(5000)
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Wait time in milliseconds before capturing the PDF (0-5000)."),
|
|
45
|
+
expires: z
|
|
46
|
+
.number()
|
|
47
|
+
.min(1)
|
|
48
|
+
.max(604800)
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("Automatically delete the generated PDF after this many seconds (1-604800)."),
|
|
51
|
+
});
|
|
52
|
+
export const getRenderResultsParameters = z.object({
|
|
53
|
+
template: z.string().optional().describe("Filter results by template identifier."),
|
|
54
|
+
batch: z.string().optional().describe("Filter results by batch identifier."),
|
|
55
|
+
page: z.number().min(0).optional().describe("Page number for pagination (default 0)."),
|
|
56
|
+
size: z.number().min(1).max(50).optional().describe("Page size for pagination (default 20, max 50)."),
|
|
57
|
+
});
|
|
58
|
+
export const getRenderResultParameters = z.object({
|
|
59
|
+
identifier: z.string().min(1).describe("Identifier (requestId) of the render result, e.g. req-xxxx."),
|
|
60
|
+
});
|
|
61
|
+
export const deleteRenderResultParameters = z.object({
|
|
62
|
+
identifier: z.string().min(1).describe("Identifier (requestId) of the render result to delete."),
|
|
63
|
+
});
|
|
64
|
+
export const getTemplatesParameters = z.object({
|
|
65
|
+
name: z.string().optional().describe("Filter templates by name."),
|
|
66
|
+
tags: z.array(z.string()).optional().describe("Filter templates by tags."),
|
|
67
|
+
sourceTemplateId: z
|
|
68
|
+
.string()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Filter by the identifier of the source template used to create a template."),
|
|
71
|
+
page: z.number().min(0).optional().describe("Page number for pagination (default 0)."),
|
|
72
|
+
size: z.number().min(1).max(50).optional().describe("Page size for pagination (default 20, max 50)."),
|
|
73
|
+
});
|
|
74
|
+
export const getTemplateParameters = z.object({
|
|
75
|
+
templateId: z.string().min(1).describe("Identifier of the template to fetch."),
|
|
76
|
+
});
|
|
77
|
+
export const deleteTemplateParameters = z.object({
|
|
78
|
+
templateId: z.string().min(1).describe("Identifier of the template to delete."),
|
|
79
|
+
});
|
|
80
|
+
export const getUsageParameters = z.object({}).describe("No parameters required.");
|
|
81
|
+
export const getFontsParameters = z.object({}).describe("No parameters required.");
|
package/build/prompts.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const renderImagePrompt = `
|
|
2
|
+
This tool renders an image, PDF or video from a RenderForm template.
|
|
3
|
+
- Provide 'template' (required): the template ID, e.g. template_1234.
|
|
4
|
+
- Provide 'data' to merge dynamic content into the template. Keys follow the 'componentId.property' convention (e.g. { "my-text.text": "Hello World!", "my-image.src": "https://example.com/image.jpg" }).
|
|
5
|
+
- Component IDs and editable properties can be discovered with the 'get_template' tool (see the 'properties' field of the template).
|
|
6
|
+
- Optionally provide 'fileName', 'webhookUrl' (called when the render finishes), 'version' (cache key - reusing it returns a cached result instead of re-rendering), 'metadata' (passed through to the webhook), 'batchName' (to group renders together) and 'waitTime' (delay before rendering, max 5000ms).
|
|
7
|
+
- Use 'output: json' (default) to get back a JSON object with the href of the rendered file. Avoid 'output: image' here since it returns raw binary bytes.
|
|
8
|
+
`;
|
|
9
|
+
export const createScreenshotPrompt = `
|
|
10
|
+
This tool captures a screenshot of a web page using RenderForm.
|
|
11
|
+
- Provide 'url' (required), 'width' and 'height' (required, 32-5000px).
|
|
12
|
+
- Optionally provide 'waitTime' (ms, 0-5000) to wait before capturing, useful for pages with animations or async content.
|
|
13
|
+
`;
|
|
14
|
+
export const createPdfPrompt = `
|
|
15
|
+
This tool converts a web page into a PDF using RenderForm.
|
|
16
|
+
- Provide 'url' (required).
|
|
17
|
+
- Optionally provide 'format' (A5, A4, A3, LETTER or LEGAL - defaults to A4), 'waitTime' (ms, 0-5000) before capturing, and 'expires' (seconds, 1-604800) to auto-delete the generated PDF.
|
|
18
|
+
`;
|
|
19
|
+
export const getRenderResultsPrompt = `
|
|
20
|
+
This tool lists past render results (images, PDFs, screenshots) in your RenderForm account.
|
|
21
|
+
- Optionally filter by 'template' or 'batch' identifier.
|
|
22
|
+
- Supports pagination with 'page' (default 0) and 'size' (default 20, max 50).
|
|
23
|
+
`;
|
|
24
|
+
export const getRenderResultPrompt = `
|
|
25
|
+
This tool retrieves details of a single render result by its identifier (requestId).
|
|
26
|
+
- Provide 'identifier' (required), returned as 'requestId' from the render/screenshot/pdf tools.
|
|
27
|
+
- Returns status, dimensions, href, template info and timestamps.
|
|
28
|
+
`;
|
|
29
|
+
export const deleteRenderResultPrompt = `
|
|
30
|
+
This tool permanently deletes a render result (and its file) from your RenderForm account.
|
|
31
|
+
- Provide 'identifier' (required), the requestId of the result to delete.
|
|
32
|
+
- This action is destructive and cannot be undone.
|
|
33
|
+
`;
|
|
34
|
+
export const getTemplatesPrompt = `
|
|
35
|
+
This tool lists templates available in your RenderForm account.
|
|
36
|
+
- Optionally filter by 'name', 'tags' or 'sourceTemplateId'.
|
|
37
|
+
- Supports pagination with 'page' (default 0) and 'size' (default 20, max 50).
|
|
38
|
+
- Use this to find a template identifier before rendering or fetching template details.
|
|
39
|
+
`;
|
|
40
|
+
export const getTemplatePrompt = `
|
|
41
|
+
This tool retrieves the full details of a single template, including its editable 'properties' (component IDs, property names and default values), fonts and tags.
|
|
42
|
+
- Provide 'templateId' (required).
|
|
43
|
+
- Use the returned 'properties' to build the 'data' object for the 'render_image' tool.
|
|
44
|
+
`;
|
|
45
|
+
export const deleteTemplatePrompt = `
|
|
46
|
+
This tool permanently deletes a template from your RenderForm account.
|
|
47
|
+
- Provide 'templateId' (required).
|
|
48
|
+
- This action is destructive and cannot be undone.
|
|
49
|
+
`;
|
|
50
|
+
export const getUsagePrompt = `
|
|
51
|
+
This tool returns the organization's usage summary: render credits (used/total/renewal), file storage uploads (used/total bytes) and plan/billing status.
|
|
52
|
+
- No parameters required.
|
|
53
|
+
- Use this to check remaining credits before running large render batches.
|
|
54
|
+
`;
|
|
55
|
+
export const getFontsPrompt = `
|
|
56
|
+
This tool lists fonts available in your RenderForm account, including Google fonts and any custom uploaded fonts.
|
|
57
|
+
- No parameters required.
|
|
58
|
+
- Use this to find a valid font family name to use in a template.
|
|
59
|
+
`;
|
package/build/toolkit.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import RenderFormAPI from "./api.js";
|
|
3
|
+
import tools from "./tools.js";
|
|
4
|
+
class RenderFormMCPServer extends McpServer {
|
|
5
|
+
_renderForm;
|
|
6
|
+
constructor({ apiKey }) {
|
|
7
|
+
super({
|
|
8
|
+
name: "renderform",
|
|
9
|
+
version: "0.1.0",
|
|
10
|
+
});
|
|
11
|
+
this._renderForm = new RenderFormAPI(apiKey);
|
|
12
|
+
tools.forEach((tool) => {
|
|
13
|
+
this.tool(tool.method, tool.description, tool.parameters.shape, tool.annotations, async (arg, _extra) => {
|
|
14
|
+
const result = await this._renderForm.run(tool.method, arg);
|
|
15
|
+
return {
|
|
16
|
+
content: [
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
text: String(result),
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export default RenderFormMCPServer;
|
package/build/tools.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createPdfParameters, createScreenshotParameters, deleteRenderResultParameters, deleteTemplateParameters, getFontsParameters, getRenderResultParameters, getRenderResultsParameters, getTemplateParameters, getTemplatesParameters, getUsageParameters, renderImageParameters, } from "./parameters.js";
|
|
2
|
+
import { createPdfPrompt, createScreenshotPrompt, deleteRenderResultPrompt, deleteTemplatePrompt, getFontsPrompt, getRenderResultPrompt, getRenderResultsPrompt, getTemplatePrompt, getTemplatesPrompt, getUsagePrompt, renderImagePrompt, } from "./prompts.js";
|
|
3
|
+
const readOnly = {
|
|
4
|
+
readOnlyHint: true,
|
|
5
|
+
destructiveHint: false,
|
|
6
|
+
idempotentHint: true,
|
|
7
|
+
openWorldHint: true,
|
|
8
|
+
};
|
|
9
|
+
const createOrUpdate = {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: false,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
};
|
|
15
|
+
const destructive = {
|
|
16
|
+
readOnlyHint: false,
|
|
17
|
+
destructiveHint: true,
|
|
18
|
+
idempotentHint: false,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
};
|
|
21
|
+
const tools = [
|
|
22
|
+
{
|
|
23
|
+
method: "render_image",
|
|
24
|
+
name: "Render Image",
|
|
25
|
+
description: renderImagePrompt,
|
|
26
|
+
parameters: renderImageParameters,
|
|
27
|
+
annotations: createOrUpdate,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
method: "create_screenshot",
|
|
31
|
+
name: "Create Screenshot",
|
|
32
|
+
description: createScreenshotPrompt,
|
|
33
|
+
parameters: createScreenshotParameters,
|
|
34
|
+
annotations: createOrUpdate,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
method: "create_pdf",
|
|
38
|
+
name: "Create PDF",
|
|
39
|
+
description: createPdfPrompt,
|
|
40
|
+
parameters: createPdfParameters,
|
|
41
|
+
annotations: createOrUpdate,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
method: "get_render_results",
|
|
45
|
+
name: "Get Render Results",
|
|
46
|
+
description: getRenderResultsPrompt,
|
|
47
|
+
parameters: getRenderResultsParameters,
|
|
48
|
+
annotations: readOnly,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
method: "get_render_result",
|
|
52
|
+
name: "Get Render Result",
|
|
53
|
+
description: getRenderResultPrompt,
|
|
54
|
+
parameters: getRenderResultParameters,
|
|
55
|
+
annotations: readOnly,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
method: "delete_render_result",
|
|
59
|
+
name: "Delete Render Result",
|
|
60
|
+
description: deleteRenderResultPrompt,
|
|
61
|
+
parameters: deleteRenderResultParameters,
|
|
62
|
+
annotations: destructive,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
method: "get_templates",
|
|
66
|
+
name: "Get Templates",
|
|
67
|
+
description: getTemplatesPrompt,
|
|
68
|
+
parameters: getTemplatesParameters,
|
|
69
|
+
annotations: readOnly,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
method: "get_template",
|
|
73
|
+
name: "Get Template",
|
|
74
|
+
description: getTemplatePrompt,
|
|
75
|
+
parameters: getTemplateParameters,
|
|
76
|
+
annotations: readOnly,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
method: "delete_template",
|
|
80
|
+
name: "Delete Template",
|
|
81
|
+
description: deleteTemplatePrompt,
|
|
82
|
+
parameters: deleteTemplateParameters,
|
|
83
|
+
annotations: destructive,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
method: "get_usage",
|
|
87
|
+
name: "Get Usage",
|
|
88
|
+
description: getUsagePrompt,
|
|
89
|
+
parameters: getUsageParameters,
|
|
90
|
+
annotations: readOnly,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
method: "get_fonts",
|
|
94
|
+
name: "Get Fonts",
|
|
95
|
+
description: getFontsPrompt,
|
|
96
|
+
parameters: getFontsParameters,
|
|
97
|
+
annotations: readOnly,
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
export default tools;
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "renderform-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP Server for RenderForm.io",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/renderform/renderform-mcp-server.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "build/index.js",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"renderform": "build/index.js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"inspector": "npx @modelcontextprotocol/inspector build/index.js",
|
|
19
|
+
"lint": "eslint src",
|
|
20
|
+
"lint:fix": "eslint src --fix",
|
|
21
|
+
"format": "prettier --write src"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"build"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"mcp",
|
|
28
|
+
"modelcontextprotocol",
|
|
29
|
+
"renderform",
|
|
30
|
+
"image-generation",
|
|
31
|
+
"pdf"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@modelcontextprotocol/sdk": "^1.7.0",
|
|
35
|
+
"typescript": "^5.8.2",
|
|
36
|
+
"zod": "^3.24.2",
|
|
37
|
+
"axios": "^1.6.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^9.23.0",
|
|
41
|
+
"@types/node": "^22.13.12",
|
|
42
|
+
"eslint": "^9.23.0",
|
|
43
|
+
"globals": "^16.0.0",
|
|
44
|
+
"prettier": "^3.5.3",
|
|
45
|
+
"typescript-eslint": "^8.27.0"
|
|
46
|
+
}
|
|
47
|
+
}
|