@publishq/mcp 0.0.1
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 +201 -0
- package/README.md +86 -0
- package/dist/index.js +300 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 Derivative
|
|
95
|
+
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 do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 PublishQ
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://publishq.com/favicon.svg" width="80" alt="PublishQ logo" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@publishq/mcp</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@publishq/mcp"><img src="https://img.shields.io/npm/v/@publishq/mcp.svg" alt="npm version"></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>A Model Context Protocol server that lets AI agents schedule and publish across your social platforms through PublishQ.</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
This is the official [MCP](https://modelcontextprotocol.io) server for [PublishQ](https://publishq.com). Point Claude Desktop, Cursor, or any MCP-compatible agent at it and they can list your connected accounts, create and schedule posts, manage workspaces, and upload media — all through the [PublishQ API](https://publishq.com/docs).
|
|
16
|
+
|
|
17
|
+
It runs locally over stdio and talks to the PublishQ API using your API key.
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
You need a PublishQ API key. Create one under **Settings → API Keys** in the PublishQ dashboard (it starts with `pq_live_`).
|
|
22
|
+
|
|
23
|
+
### Claude Desktop
|
|
24
|
+
|
|
25
|
+
Add this to your `claude_desktop_config.json`:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"publishq": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "@publishq/mcp"],
|
|
33
|
+
"env": {
|
|
34
|
+
"PUBLISHQ_API_KEY": "pq_live_your_key_here"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Restart Claude Desktop and you'll see the PublishQ tools available. Now you can say things like *"Schedule a post to my Twitter and LinkedIn for tomorrow at 9am"* and the agent will use the tools below.
|
|
42
|
+
|
|
43
|
+
### Other clients (Cursor, Windsurf, etc.)
|
|
44
|
+
|
|
45
|
+
Any MCP client that launches a stdio server works the same way — run the command `npx -y @publishq/mcp` with `PUBLISHQ_API_KEY` set in the environment.
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
| Variable | Required | Description |
|
|
50
|
+
| ------------------ | -------- | ------------------------------------------------------------------ |
|
|
51
|
+
| `PUBLISHQ_API_KEY` | Yes | Your PublishQ API key (`pq_live_...`). |
|
|
52
|
+
| `PUBLISHQ_API_URL` | No | Override the API base URL (defaults to `https://publishq.com/api/v1`). |
|
|
53
|
+
|
|
54
|
+
## Tools
|
|
55
|
+
|
|
56
|
+
| Tool | What it does |
|
|
57
|
+
| ----------------------------------- | ------------------------------------------------------- |
|
|
58
|
+
| `publishq_list_posts` | List posts (paginated) |
|
|
59
|
+
| `publishq_get_post` | Get one post by ID |
|
|
60
|
+
| `publishq_create_post` | Create a draft, scheduled, or immediate post |
|
|
61
|
+
| `publishq_update_post` | Update a draft or scheduled post |
|
|
62
|
+
| `publishq_delete_post` | Delete a post |
|
|
63
|
+
| `publishq_remove_post_account` | Remove one account from a post |
|
|
64
|
+
| `publishq_list_accounts` | List connected social accounts (filter by platform) |
|
|
65
|
+
| `publishq_get_tiktok_creator_info` | Read TikTok creator info before posting |
|
|
66
|
+
| `publishq_list_workspaces` | List workspaces |
|
|
67
|
+
| `publishq_get_workspace` | Get one workspace by ID |
|
|
68
|
+
| `publishq_create_workspace` | Create a workspace |
|
|
69
|
+
| `publishq_list_media` | List uploaded/generated media |
|
|
70
|
+
| `publishq_get_media` | Get one media file by ID |
|
|
71
|
+
| `publishq_upload_media` | Upload a local file and get a media ID |
|
|
72
|
+
|
|
73
|
+
The tools are thin wrappers over [`@publishq/sdk`](https://www.npmjs.com/package/@publishq/sdk), so their behavior and scopes match the [PublishQ API](https://publishq.com/docs). `publishq_create_post` accepts an `accounts` array whose entries contain `accountId` plus optional `postOverrides` and `platformSpecificSettings`. `publishq_update_post` accepts content, scheduling, complete media replacement or removal, and thumbnail timestamp changes. `publishq_list_media` can filter by media IDs, types, and sources. For TikTok, the agent should call `publishq_get_tiktok_creator_info` first and then provide the required privacy and interaction settings in that account object. A tool call that hits an API error returns the API error so the agent can react.
|
|
74
|
+
|
|
75
|
+
## Scopes
|
|
76
|
+
|
|
77
|
+
Tools require the same API-key scopes as the underlying endpoints: `posts:read`/`posts:write`, `accounts:read`, `workspaces:read`/`workspaces:write`, and `media:read`/`media:write`. Grant a key only the scopes your agent needs.
|
|
78
|
+
|
|
79
|
+
## Related
|
|
80
|
+
|
|
81
|
+
- [`@publishq/sdk`](https://www.npmjs.com/package/@publishq/sdk) — the TypeScript SDK this server is built on.
|
|
82
|
+
- [`@publishq/cli`](https://www.npmjs.com/package/@publishq/cli) — command-line interface for the same API.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
[Apache-2.0](./LICENSE)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { readFileSync } from "fs";
|
|
5
|
+
import { basename } from "path";
|
|
6
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
|
+
import {
|
|
9
|
+
CallToolRequestSchema,
|
|
10
|
+
ErrorCode,
|
|
11
|
+
ListToolsRequestSchema,
|
|
12
|
+
McpError
|
|
13
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
14
|
+
import PublishQ, {
|
|
15
|
+
zCreatePostBody,
|
|
16
|
+
zCreateWorkspaceBody,
|
|
17
|
+
zDeletePostPath,
|
|
18
|
+
zGetMediaPath,
|
|
19
|
+
zGetPostPath,
|
|
20
|
+
zGetTikTokCreatorInfoPath,
|
|
21
|
+
zGetWorkspacePath,
|
|
22
|
+
zListAccountsQuery,
|
|
23
|
+
zListMediaQuery,
|
|
24
|
+
zListPostsQuery,
|
|
25
|
+
zRemovePostAccountPath,
|
|
26
|
+
zUpdatePostBody,
|
|
27
|
+
zUpdatePostPath
|
|
28
|
+
} from "@publishq/sdk";
|
|
29
|
+
import { toJSONSchema } from "zod/v4-mini";
|
|
30
|
+
var API_KEY = process.env.PUBLISHQ_API_KEY;
|
|
31
|
+
if (!API_KEY) {
|
|
32
|
+
console.error(
|
|
33
|
+
"ERROR: PUBLISHQ_API_KEY environment variable is required. Create a key at https://publishq.com/app/settings."
|
|
34
|
+
);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
var publishq = new PublishQ({
|
|
38
|
+
apiKey: API_KEY,
|
|
39
|
+
...process.env.PUBLISHQ_API_URL ? { baseUrl: process.env.PUBLISHQ_API_URL } : {}
|
|
40
|
+
});
|
|
41
|
+
function describeError(error) {
|
|
42
|
+
const cause = error.cause;
|
|
43
|
+
if (cause instanceof Error) {
|
|
44
|
+
const code = cause.code;
|
|
45
|
+
return code ? `${cause.message} (${code})` : cause.message;
|
|
46
|
+
}
|
|
47
|
+
return error.message;
|
|
48
|
+
}
|
|
49
|
+
function errorResult(error) {
|
|
50
|
+
return {
|
|
51
|
+
content: [
|
|
52
|
+
{
|
|
53
|
+
type: "text",
|
|
54
|
+
text: `Error: ${error instanceof Error ? describeError(error) : String(error)}`
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
isError: true
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function run(call) {
|
|
61
|
+
try {
|
|
62
|
+
const { data, error, response } = await call;
|
|
63
|
+
if (error !== void 0 || response && !response.ok) {
|
|
64
|
+
const text = error instanceof Error ? `Error: ${describeError(error)}` : error !== void 0 ? typeof error === "string" ? error : JSON.stringify(error, null, 2) ?? String(error) : `Request failed${response ? ` (${`${response.status} ${response.statusText}`.trim()})` : ""}`;
|
|
65
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
66
|
+
}
|
|
67
|
+
const payload = response?.status === 204 ? { success: true } : data ?? {};
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return errorResult(error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function advertisedSchema(schema) {
|
|
76
|
+
const jsonSchema = toJSONSchema(schema, { io: "input", target: "draft-7" });
|
|
77
|
+
if (jsonSchema.type !== "object") {
|
|
78
|
+
throw new Error("MCP tool input schema must describe an object.");
|
|
79
|
+
}
|
|
80
|
+
return jsonSchema;
|
|
81
|
+
}
|
|
82
|
+
function mergedAdvertisedSchema(...schemas) {
|
|
83
|
+
const converted = schemas.map(advertisedSchema);
|
|
84
|
+
const required = [
|
|
85
|
+
...new Set(converted.flatMap((schema) => schema.required ?? []))
|
|
86
|
+
];
|
|
87
|
+
return {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: Object.assign(
|
|
90
|
+
{},
|
|
91
|
+
...converted.map((schema) => schema.properties ?? {})
|
|
92
|
+
),
|
|
93
|
+
...required.length ? { required } : {},
|
|
94
|
+
additionalProperties: false
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
var tools = /* @__PURE__ */ new Map();
|
|
98
|
+
function registerTool(definition, handler) {
|
|
99
|
+
tools.set(definition.name, { definition, handler });
|
|
100
|
+
}
|
|
101
|
+
registerTool(
|
|
102
|
+
{
|
|
103
|
+
name: "publishq_list_posts",
|
|
104
|
+
title: "List posts",
|
|
105
|
+
description: "List the posts on the authenticated PublishQ account. Paginated. Each post includes its connected accounts and status (DRAFT, SCHEDULED, PUBLISHING, PUBLISHED, FAILED).",
|
|
106
|
+
inputSchema: advertisedSchema(zListPostsQuery),
|
|
107
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
108
|
+
},
|
|
109
|
+
(args) => run(publishq.posts.list(args))
|
|
110
|
+
);
|
|
111
|
+
registerTool(
|
|
112
|
+
{
|
|
113
|
+
name: "publishq_get_post",
|
|
114
|
+
title: "Get a post",
|
|
115
|
+
description: "Get one post by its PublishQ post ID.",
|
|
116
|
+
inputSchema: advertisedSchema(zGetPostPath),
|
|
117
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
118
|
+
},
|
|
119
|
+
(args) => run(publishq.posts.get(args.id))
|
|
120
|
+
);
|
|
121
|
+
registerTool(
|
|
122
|
+
{
|
|
123
|
+
name: "publishq_create_post",
|
|
124
|
+
title: "Create a post",
|
|
125
|
+
description: "Create a post for one or more connected accounts. Get account IDs from publishq_list_accounts. Each account accepts postOverrides and platformSpecificSettings. Before posting to TikTok, call publishq_get_tiktok_creator_info and include all required TikTok settings. Omit both scheduledAt and publishNow to save as a draft; set publishNow to publish immediately, or scheduledAt (ISO 8601) to schedule for later.",
|
|
126
|
+
inputSchema: advertisedSchema(zCreatePostBody),
|
|
127
|
+
annotations: { readOnlyHint: false, openWorldHint: true }
|
|
128
|
+
},
|
|
129
|
+
(args) => run(publishq.posts.create(args))
|
|
130
|
+
);
|
|
131
|
+
registerTool(
|
|
132
|
+
{
|
|
133
|
+
name: "publishq_update_post",
|
|
134
|
+
title: "Update a post",
|
|
135
|
+
description: "Update a draft or scheduled post. Supports content, scheduledAt, complete media replacement/removal through mediaIds, and thumbnailTimestamp. Published and publishing posts cannot be updated.",
|
|
136
|
+
inputSchema: mergedAdvertisedSchema(zUpdatePostPath, zUpdatePostBody),
|
|
137
|
+
annotations: { readOnlyHint: false, idempotentHint: true, openWorldHint: true }
|
|
138
|
+
},
|
|
139
|
+
(args) => {
|
|
140
|
+
const { id, ...body } = args;
|
|
141
|
+
return run(
|
|
142
|
+
publishq.posts.update(id, body)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
registerTool(
|
|
147
|
+
{
|
|
148
|
+
name: "publishq_delete_post",
|
|
149
|
+
title: "Delete a post",
|
|
150
|
+
description: "Delete a scheduled or draft post by its ID. This cannot be undone.",
|
|
151
|
+
inputSchema: advertisedSchema(zDeletePostPath),
|
|
152
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
153
|
+
},
|
|
154
|
+
(args) => run(publishq.posts.delete(args.id))
|
|
155
|
+
);
|
|
156
|
+
registerTool(
|
|
157
|
+
{
|
|
158
|
+
name: "publishq_remove_post_account",
|
|
159
|
+
title: "Remove an account from a post",
|
|
160
|
+
description: "Remove one account from an existing post so it will no longer be published there. Other accounts in the same post are unaffected.",
|
|
161
|
+
inputSchema: advertisedSchema(zRemovePostAccountPath),
|
|
162
|
+
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: true }
|
|
163
|
+
},
|
|
164
|
+
(args) => run(
|
|
165
|
+
publishq.posts.removeAccount(
|
|
166
|
+
args.id,
|
|
167
|
+
args.accountId
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
registerTool(
|
|
172
|
+
{
|
|
173
|
+
name: "publishq_list_accounts",
|
|
174
|
+
title: "List connected accounts",
|
|
175
|
+
description: "List the social accounts connected to the authenticated PublishQ account. Optionally filter by workspace and platform. Use the returned account IDs when creating posts.",
|
|
176
|
+
inputSchema: advertisedSchema(zListAccountsQuery),
|
|
177
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
178
|
+
},
|
|
179
|
+
(args) => run(publishq.accounts.list(args))
|
|
180
|
+
);
|
|
181
|
+
registerTool(
|
|
182
|
+
{
|
|
183
|
+
name: "publishq_get_tiktok_creator_info",
|
|
184
|
+
title: "Get TikTok creator info",
|
|
185
|
+
description: "Get a TikTok account's current privacy options, interaction settings, and max video duration. Call this before creating a TikTok post \u2014 the privacyLevel you set must be one of the returned privacyLevelOptions.",
|
|
186
|
+
inputSchema: advertisedSchema(zGetTikTokCreatorInfoPath),
|
|
187
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
188
|
+
},
|
|
189
|
+
(args) => run(publishq.accounts.getTikTokCreatorInfo(args.id))
|
|
190
|
+
);
|
|
191
|
+
registerTool(
|
|
192
|
+
{
|
|
193
|
+
name: "publishq_list_workspaces",
|
|
194
|
+
title: "List workspaces",
|
|
195
|
+
description: "List your workspaces, including their names, colors, and account counts.",
|
|
196
|
+
inputSchema: { type: "object", properties: {} },
|
|
197
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
198
|
+
},
|
|
199
|
+
() => run(publishq.workspaces.list())
|
|
200
|
+
);
|
|
201
|
+
registerTool(
|
|
202
|
+
{
|
|
203
|
+
name: "publishq_get_workspace",
|
|
204
|
+
title: "Get a workspace",
|
|
205
|
+
description: "Get one workspace by its ID.",
|
|
206
|
+
inputSchema: advertisedSchema(zGetWorkspacePath),
|
|
207
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
208
|
+
},
|
|
209
|
+
(args) => run(publishq.workspaces.get(args.id))
|
|
210
|
+
);
|
|
211
|
+
registerTool(
|
|
212
|
+
{
|
|
213
|
+
name: "publishq_create_workspace",
|
|
214
|
+
title: "Create a workspace",
|
|
215
|
+
description: "Create a workspace to organize your connected accounts.",
|
|
216
|
+
inputSchema: advertisedSchema(zCreateWorkspaceBody),
|
|
217
|
+
annotations: { readOnlyHint: false, openWorldHint: true }
|
|
218
|
+
},
|
|
219
|
+
(args) => run(publishq.workspaces.create(args))
|
|
220
|
+
);
|
|
221
|
+
registerTool(
|
|
222
|
+
{
|
|
223
|
+
name: "publishq_list_media",
|
|
224
|
+
title: "List media",
|
|
225
|
+
description: "List your uploaded and generated media files. Optionally filter by media ID, type, and source.",
|
|
226
|
+
inputSchema: advertisedSchema(zListMediaQuery),
|
|
227
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
228
|
+
},
|
|
229
|
+
(args) => run(publishq.media.list(args))
|
|
230
|
+
);
|
|
231
|
+
registerTool(
|
|
232
|
+
{
|
|
233
|
+
name: "publishq_get_media",
|
|
234
|
+
title: "Get a media file",
|
|
235
|
+
description: "Get one media file by its ID, including its URL and usage.",
|
|
236
|
+
inputSchema: advertisedSchema(zGetMediaPath),
|
|
237
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
238
|
+
},
|
|
239
|
+
(args) => run(publishq.media.get(args.id))
|
|
240
|
+
);
|
|
241
|
+
registerTool(
|
|
242
|
+
{
|
|
243
|
+
name: "publishq_upload_media",
|
|
244
|
+
title: "Upload a media file",
|
|
245
|
+
description: "Upload a local media file to PublishQ and get back a media ID you can attach to posts via publishq_create_post (mediaIds). The file is read from the local filesystem where this MCP server runs.",
|
|
246
|
+
inputSchema: {
|
|
247
|
+
type: "object",
|
|
248
|
+
properties: {
|
|
249
|
+
filePath: {
|
|
250
|
+
type: "string",
|
|
251
|
+
description: "Absolute path to the local file to upload"
|
|
252
|
+
},
|
|
253
|
+
filename: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "Override the uploaded file name"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
required: ["filePath"],
|
|
259
|
+
additionalProperties: false
|
|
260
|
+
},
|
|
261
|
+
annotations: { readOnlyHint: false, openWorldHint: true }
|
|
262
|
+
},
|
|
263
|
+
(args) => {
|
|
264
|
+
const filePath = args.filePath;
|
|
265
|
+
const filename = args.filename;
|
|
266
|
+
const buffer = readFileSync(filePath);
|
|
267
|
+
const file = new File([buffer], filename ?? basename(filePath));
|
|
268
|
+
return run(publishq.media.upload({ file }));
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
var server = new McpServer(
|
|
272
|
+
{ name: "publishq", version: "0.1.0" },
|
|
273
|
+
{ capabilities: { tools: {} } }
|
|
274
|
+
);
|
|
275
|
+
server.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
276
|
+
tools: [...tools.values()].map(({ definition }) => definition)
|
|
277
|
+
}));
|
|
278
|
+
server.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
279
|
+
const registered = tools.get(request.params.name);
|
|
280
|
+
if (!registered) {
|
|
281
|
+
throw new McpError(
|
|
282
|
+
ErrorCode.InvalidParams,
|
|
283
|
+
`Unknown tool: ${request.params.name}`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
return await registered.handler(request.params.arguments ?? {});
|
|
288
|
+
} catch (error) {
|
|
289
|
+
return errorResult(error);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
async function main() {
|
|
293
|
+
const transport = new StdioServerTransport();
|
|
294
|
+
await server.connect(transport);
|
|
295
|
+
console.error("PublishQ MCP server running on stdio");
|
|
296
|
+
}
|
|
297
|
+
main().catch((error) => {
|
|
298
|
+
console.error("Fatal error running the PublishQ MCP server:", error);
|
|
299
|
+
process.exit(1);
|
|
300
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@publishq/mcp",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Model Context Protocol (MCP) server for PublishQ — let AI agents schedule and publish across your social platforms.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "PublishQ",
|
|
8
|
+
"homepage": "https://publishq.com",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"publishq",
|
|
11
|
+
"mcp",
|
|
12
|
+
"model-context-protocol",
|
|
13
|
+
"ai-agent",
|
|
14
|
+
"claude",
|
|
15
|
+
"social-media"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": {
|
|
19
|
+
"publishq-mcp": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@modelcontextprotocol/sdk": "1.29.0",
|
|
28
|
+
"zod": "4.4.3",
|
|
29
|
+
"@publishq/sdk": "^0.0.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^20",
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^5",
|
|
35
|
+
"vitest": "3.2.4"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"dev": "tsup --watch",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"lint": "eslint src tests --max-warnings 0",
|
|
48
|
+
"test": "pnpm build && vitest run"
|
|
49
|
+
}
|
|
50
|
+
}
|