@apiwings/mcp 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +55 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +14 -0
- package/dist/tools.d.ts +103 -0
- package/dist/tools.js +179 -0
- package/package.json +50 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LV Tech Labs, S.L.U.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @apiwings/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for [APIWings](https://apiwings.com): lets Claude, Cursor or any MCP client connect social accounts and publish to Instagram, Facebook, Threads, LinkedIn, TikTok, YouTube, Bluesky, X and Pinterest.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
| Tool | What it does |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `list_profiles` / `create_profile` | Profiles (one per end customer) |
|
|
10
|
+
| `connect` | Link for the user to connect a network |
|
|
11
|
+
| `list_accounts` | Connected accounts of a profile |
|
|
12
|
+
| `publish_options` | What a network requires you to show before posting (for example TikTok's creator info) |
|
|
13
|
+
| `upload_media` | Upload a local file and get its media id |
|
|
14
|
+
| `validate_post` | Check a post without publishing anything (result per network) |
|
|
15
|
+
| `create_post` | Publish now or schedule |
|
|
16
|
+
| `get_post` / `list_posts` | Status, URL, visibility and error per network |
|
|
17
|
+
| `cancel_post` | Cancel a scheduled post that has not started |
|
|
18
|
+
|
|
19
|
+
## Remote server (nothing to install)
|
|
20
|
+
|
|
21
|
+
APIWings also runs this server for you at `https://mcp.apiwings.com/mcp`. Add that URL to Claude (Settings → Connectors → Add custom connector), Claude Code (`claude mcp add --transport http apiwings https://mcp.apiwings.com/mcp`) or Cursor, and sign in to APIWings. See the [MCP guide](https://apiwings.com/docs/mcp).
|
|
22
|
+
|
|
23
|
+
## Local setup (this package)
|
|
24
|
+
|
|
25
|
+
Create an API key in the APIWings dashboard under **API keys**. Start with a test key (`aw_test_`): the agent can try everything and nothing is posted. The key goes in the server's environment, never in the conversation.
|
|
26
|
+
|
|
27
|
+
**Claude Desktop:** the easiest way is the one-click extension from [apiwings.com/docs/mcp](https://apiwings.com/docs/mcp), which asks for the key in a form. Or add this to `claude_desktop_config.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"mcpServers": {
|
|
32
|
+
"apiwings": {
|
|
33
|
+
"command": "npx",
|
|
34
|
+
"args": ["-y", "@apiwings/mcp"],
|
|
35
|
+
"env": {
|
|
36
|
+
"APIWINGS_API_KEY": "aw_test_...",
|
|
37
|
+
"APIWINGS_BASE_URL": "https://api-staging.apiwings.com"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Claude Code:**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
claude mcp add apiwings -e APIWINGS_API_KEY=aw_test_... -e APIWINGS_BASE_URL=https://api-staging.apiwings.com -- npx -y @apiwings/mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Cursor and other clients:** the same `command`, `args` and `env` as above in their MCP settings.
|
|
51
|
+
|
|
52
|
+
`APIWINGS_BASE_URL` is the current API address (`https://api-staging.apiwings.com`). `create_post` creates the idempotency key if the agent does not pass one. Errors come back as readable text with the code, the network's message and a link to the docs.
|
|
53
|
+
|
|
54
|
+
Documentation: [MCP guide](https://apiwings.com/docs/mcp) · [quickstart](https://apiwings.com/docs/quickstart) · support@apiwings.com
|
|
55
|
+
|
|
56
|
+
MIT License · LV Tech Labs, S.L.U.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { ApiWings } from "@apiwings/sdk";
|
|
5
|
+
import { buildTools, registerTools } from "./tools.js";
|
|
6
|
+
const apiKey = process.env.APIWINGS_API_KEY;
|
|
7
|
+
if (!apiKey) {
|
|
8
|
+
console.error("APIWINGS_API_KEY is required (aw_live_… or aw_test_…). Optional: APIWINGS_BASE_URL.");
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
const server = new McpServer({ name: "apiwings", version: "0.2.0" });
|
|
12
|
+
registerTools(server, buildTools(new ApiWings({ apiKey, baseUrl: process.env.APIWINGS_BASE_URL })));
|
|
13
|
+
await server.connect(new StdioServerTransport());
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ApiWings } from "@apiwings/sdk";
|
|
3
|
+
export interface Tool<S extends z.ZodRawShape = z.ZodRawShape> {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: S;
|
|
7
|
+
run: (args: z.objectOutputType<S, z.ZodTypeAny>) => Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildTools(aw: ApiWings, fetchFn?: typeof fetch): (Tool<{
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
before: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}> | Tool<{
|
|
13
|
+
name: z.ZodOptional<z.ZodString>;
|
|
14
|
+
external_id: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}> | Tool<{
|
|
16
|
+
profile_id: z.ZodString;
|
|
17
|
+
platform: z.ZodEnum<["bluesky", "linkedin", "instagram", "facebook", "threads", "tiktok", "youtube", "x", "pinterest"]>;
|
|
18
|
+
redirect_url: z.ZodOptional<z.ZodString>;
|
|
19
|
+
bluesky_identifier: z.ZodOptional<z.ZodString>;
|
|
20
|
+
bluesky_app_password: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}> | Tool<{
|
|
22
|
+
file_path: z.ZodString;
|
|
23
|
+
}> | Tool<{
|
|
24
|
+
idempotency_key: z.ZodOptional<z.ZodString>;
|
|
25
|
+
profile_id: z.ZodString;
|
|
26
|
+
content: z.ZodString;
|
|
27
|
+
platforms: z.ZodArray<z.ZodObject<{
|
|
28
|
+
platform: z.ZodEnum<["bluesky", "linkedin", "instagram", "facebook", "threads", "tiktok", "youtube", "x", "pinterest"]>;
|
|
29
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
30
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
platform: "bluesky" | "linkedin" | "instagram" | "facebook" | "threads" | "tiktok" | "youtube" | "x" | "pinterest";
|
|
33
|
+
options?: Record<string, unknown> | undefined;
|
|
34
|
+
account_id?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
platform: "bluesky" | "linkedin" | "instagram" | "facebook" | "threads" | "tiktok" | "youtube" | "x" | "pinterest";
|
|
37
|
+
options?: Record<string, unknown> | undefined;
|
|
38
|
+
account_id?: string | undefined;
|
|
39
|
+
}>, "many">;
|
|
40
|
+
media: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
media_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
+
scheduled_at: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}> | Tool<{
|
|
44
|
+
profile_id: z.ZodString;
|
|
45
|
+
content: z.ZodString;
|
|
46
|
+
platforms: z.ZodArray<z.ZodObject<{
|
|
47
|
+
platform: z.ZodEnum<["bluesky", "linkedin", "instagram", "facebook", "threads", "tiktok", "youtube", "x", "pinterest"]>;
|
|
48
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
platform: "bluesky" | "linkedin" | "instagram" | "facebook" | "threads" | "tiktok" | "youtube" | "x" | "pinterest";
|
|
52
|
+
options?: Record<string, unknown> | undefined;
|
|
53
|
+
account_id?: string | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
platform: "bluesky" | "linkedin" | "instagram" | "facebook" | "threads" | "tiktok" | "youtube" | "x" | "pinterest";
|
|
56
|
+
options?: Record<string, unknown> | undefined;
|
|
57
|
+
account_id?: string | undefined;
|
|
58
|
+
}>, "many">;
|
|
59
|
+
media: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
60
|
+
media_urls: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
61
|
+
scheduled_at: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}> | Tool<{
|
|
63
|
+
profile_id: z.ZodOptional<z.ZodString>;
|
|
64
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
before: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}> | Tool<{
|
|
67
|
+
post_id: z.ZodString;
|
|
68
|
+
}> | Tool<{
|
|
69
|
+
account_id: z.ZodString;
|
|
70
|
+
}> | Tool<{
|
|
71
|
+
profile_id: z.ZodString;
|
|
72
|
+
}>)[];
|
|
73
|
+
/** Result in MCP shape; API errors become readable tool errors the agent can act on. */
|
|
74
|
+
export declare function runTool(t: ReturnType<typeof buildTools>[number], args: unknown): Promise<{
|
|
75
|
+
content: {
|
|
76
|
+
type: "text";
|
|
77
|
+
text: string;
|
|
78
|
+
}[];
|
|
79
|
+
isError?: undefined;
|
|
80
|
+
} | {
|
|
81
|
+
isError: boolean;
|
|
82
|
+
content: {
|
|
83
|
+
type: "text";
|
|
84
|
+
text: string;
|
|
85
|
+
}[];
|
|
86
|
+
}>;
|
|
87
|
+
type Annotations = {
|
|
88
|
+
readOnlyHint?: boolean;
|
|
89
|
+
destructiveHint?: boolean;
|
|
90
|
+
idempotentHint?: boolean;
|
|
91
|
+
openWorldHint?: boolean;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Title and hints of every tool (MCP tool annotations; required by Claude's connectors directory):
|
|
95
|
+
* read-only tools can run without asking, and publishing or cancelling is flagged so clients confirm first.
|
|
96
|
+
*/
|
|
97
|
+
export declare const TOOL_META: Record<string, {
|
|
98
|
+
title: string;
|
|
99
|
+
annotations: Annotations;
|
|
100
|
+
}>;
|
|
101
|
+
/** Registers the tools on an McpServer with their titles and annotations (local stdio server and the remote /mcp) */
|
|
102
|
+
export declare function registerTools(server: unknown, tools: ReturnType<typeof buildTools>): void;
|
|
103
|
+
export {};
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { ApiWingsError } from "@apiwings/sdk";
|
|
5
|
+
const PLATFORMS = ["bluesky", "linkedin", "instagram", "facebook", "threads", "tiktok", "youtube", "x", "pinterest"];
|
|
6
|
+
const MIME_BY_EXT = {
|
|
7
|
+
jpg: "image/jpeg", jpeg: "image/jpeg", png: "image/png", webp: "image/webp", gif: "image/gif", mp4: "video/mp4", mov: "video/quicktime",
|
|
8
|
+
};
|
|
9
|
+
const tool = (t) => t;
|
|
10
|
+
/** The tools of the APIWings MCP server, over the typed SDK. */
|
|
11
|
+
/** Same post shape for create_post and validate_post */
|
|
12
|
+
const postSchema = {
|
|
13
|
+
profile_id: z.string().uuid(),
|
|
14
|
+
content: z.string().max(10000),
|
|
15
|
+
platforms: z.array(z.object({
|
|
16
|
+
platform: z.enum(PLATFORMS),
|
|
17
|
+
account_id: z.string().uuid().optional().describe("Optional when the profile has a single account of that network"),
|
|
18
|
+
options: z.record(z.unknown()).optional(),
|
|
19
|
+
})).min(1).max(8),
|
|
20
|
+
media: z.array(z.string().uuid()).max(10).optional().describe("Media ids from upload_media"),
|
|
21
|
+
media_urls: z.array(z.string().url()).max(10).optional(),
|
|
22
|
+
scheduled_at: z.string().datetime().optional(),
|
|
23
|
+
};
|
|
24
|
+
export function buildTools(aw, fetchFn = fetch) {
|
|
25
|
+
return [
|
|
26
|
+
tool({
|
|
27
|
+
name: "list_profiles",
|
|
28
|
+
description: "List the profiles (one per end customer), newest first. Use next_before as before to get the next page.",
|
|
29
|
+
schema: {
|
|
30
|
+
limit: z.number().int().min(1).max(200).optional().describe("Page size (default 50)"),
|
|
31
|
+
before: z.string().datetime().optional().describe("next_before from the previous page"),
|
|
32
|
+
},
|
|
33
|
+
run: (a) => aw.profiles.list({ limit: a.limit, before: a.before }),
|
|
34
|
+
}),
|
|
35
|
+
tool({
|
|
36
|
+
name: "create_profile",
|
|
37
|
+
description: "Create a profile: one end customer whose social accounts and posts are kept apart. Returns its id, needed by connect and create_post.",
|
|
38
|
+
schema: {
|
|
39
|
+
name: z.string().max(200).optional(),
|
|
40
|
+
external_id: z.string().max(200).optional().describe("Your own id for this customer"),
|
|
41
|
+
},
|
|
42
|
+
run: (a) => aw.profiles.create({ name: a.name, external_id: a.external_id }),
|
|
43
|
+
}),
|
|
44
|
+
tool({
|
|
45
|
+
name: "connect",
|
|
46
|
+
description: "Connect a social account to a profile. Returns a hosted URL the end user must open to authorize (OAuth). " +
|
|
47
|
+
"For Bluesky pass identifier + app_password to connect directly. Never ask the user for passwords in chat except a Bluesky app password.",
|
|
48
|
+
schema: {
|
|
49
|
+
profile_id: z.string().uuid(),
|
|
50
|
+
platform: z.enum(PLATFORMS),
|
|
51
|
+
redirect_url: z.string().url().optional().describe("Where the user returns after connecting"),
|
|
52
|
+
bluesky_identifier: z.string().optional(),
|
|
53
|
+
bluesky_app_password: z.string().optional(),
|
|
54
|
+
},
|
|
55
|
+
run: (a) => aw.profiles.connect(a.profile_id, a.platform, {
|
|
56
|
+
redirect_url: a.redirect_url,
|
|
57
|
+
...(a.bluesky_identifier && a.bluesky_app_password
|
|
58
|
+
? { bluesky: { identifier: a.bluesky_identifier, app_password: a.bluesky_app_password } }
|
|
59
|
+
: {}),
|
|
60
|
+
}),
|
|
61
|
+
}),
|
|
62
|
+
tool({
|
|
63
|
+
name: "upload_media",
|
|
64
|
+
description: "Upload a local image or video (JPEG, PNG, WebP, GIF, MP4, MOV; up to 1 GB) and get a media id to use in create_post. " +
|
|
65
|
+
"If the file is already at a public https URL, skip this and pass it in create_post.media_urls.",
|
|
66
|
+
schema: { file_path: z.string().describe("Path of the file on this machine") },
|
|
67
|
+
run: async (a) => {
|
|
68
|
+
const ext = a.file_path.split(".").pop()?.toLowerCase() ?? "";
|
|
69
|
+
const mime = MIME_BY_EXT[ext];
|
|
70
|
+
if (!mime)
|
|
71
|
+
throw new Error(`Unsupported file type for ${basename(a.file_path)}; use ${Object.keys(MIME_BY_EXT).join(", ")}`);
|
|
72
|
+
const body = await readFile(a.file_path);
|
|
73
|
+
const up = (await aw.media.create({ mime, bytes: body.byteLength }));
|
|
74
|
+
const res = await fetchFn(up.upload_url, { method: "PUT", headers: { "content-type": mime }, body });
|
|
75
|
+
if (!res.ok)
|
|
76
|
+
throw new Error(`Upload failed (${res.status})`);
|
|
77
|
+
return { media_id: up.id, mime, bytes: body.byteLength };
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
tool({
|
|
81
|
+
name: "create_post",
|
|
82
|
+
description: "Publish (or schedule with scheduled_at) a post to one or more networks. Each network may have options. " +
|
|
83
|
+
"Returns the post with one target per network; poll get_post for the final state and the real visibility the platform reports.",
|
|
84
|
+
schema: {
|
|
85
|
+
...postSchema,
|
|
86
|
+
idempotency_key: z.string().min(1).optional().describe("Reuse the same key to retry safely; generated if omitted"),
|
|
87
|
+
},
|
|
88
|
+
run: (a) => aw.posts.create({ ...a, idempotency_key: a.idempotency_key ?? crypto.randomUUID() }),
|
|
89
|
+
}),
|
|
90
|
+
tool({
|
|
91
|
+
name: "validate_post",
|
|
92
|
+
description: "Check a post without publishing or creating anything: same input and same checks as create_post. " +
|
|
93
|
+
"Returns valid and, per network, valid plus the error that network would give. Use it before create_post to fix the content for each network.",
|
|
94
|
+
schema: postSchema,
|
|
95
|
+
run: (a) => aw.posts.validate(a),
|
|
96
|
+
}),
|
|
97
|
+
tool({
|
|
98
|
+
name: "list_posts",
|
|
99
|
+
description: "List posts, newest first, with each network's status, URL, visibility and error. Use next_before as before to get the next page.",
|
|
100
|
+
schema: {
|
|
101
|
+
profile_id: z.string().uuid().optional().describe("Only this profile's posts"),
|
|
102
|
+
limit: z.number().int().min(1).max(200).optional().describe("Page size (default 50)"),
|
|
103
|
+
before: z.string().datetime().optional().describe("next_before from the previous page"),
|
|
104
|
+
},
|
|
105
|
+
run: (a) => aw.posts.list({ profile_id: a.profile_id, limit: a.limit, before: a.before }),
|
|
106
|
+
}),
|
|
107
|
+
tool({
|
|
108
|
+
name: "cancel_post",
|
|
109
|
+
description: "Cancel a scheduled post that has not started publishing. Fails with a conflict if it already started or was published.",
|
|
110
|
+
schema: { post_id: z.string().uuid() },
|
|
111
|
+
run: async (a) => {
|
|
112
|
+
await aw.posts.cancel(a.post_id);
|
|
113
|
+
return { post_id: a.post_id, status: "canceled" };
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
tool({
|
|
117
|
+
name: "get_post",
|
|
118
|
+
description: "Get a post with the status, URL, visibility and error (if any) of each network.",
|
|
119
|
+
schema: { post_id: z.string().uuid() },
|
|
120
|
+
run: (a) => aw.posts.get(a.post_id),
|
|
121
|
+
}),
|
|
122
|
+
tool({
|
|
123
|
+
name: "publish_options",
|
|
124
|
+
description: "Live data a network requires you to show before publishing on an account (TikTok: creator nickname, allowed privacy levels, " +
|
|
125
|
+
"whether comments, duets and stitches can be enabled). required false means the network needs nothing.",
|
|
126
|
+
schema: { account_id: z.string().uuid() },
|
|
127
|
+
run: (a) => aw.accounts.publishOptions(a.account_id),
|
|
128
|
+
}),
|
|
129
|
+
tool({
|
|
130
|
+
name: "list_accounts",
|
|
131
|
+
description: "List the connected accounts of a profile (platform, handle, status).",
|
|
132
|
+
schema: { profile_id: z.string().uuid() },
|
|
133
|
+
run: (a) => aw.profiles.accounts(a.profile_id),
|
|
134
|
+
}),
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
/** Result in MCP shape; API errors become readable tool errors the agent can act on. */
|
|
138
|
+
export async function runTool(t, args) {
|
|
139
|
+
try {
|
|
140
|
+
const parsed = z.object(t.schema).parse(args);
|
|
141
|
+
const out = await t.run(parsed);
|
|
142
|
+
return { content: [{ type: "text", text: JSON.stringify(out, null, 2) }] };
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
const text = e instanceof ApiWingsError
|
|
146
|
+
? `${e.code}: ${e.message}${e.platformMessage ? ` (platform: ${e.platformMessage})` : ""}${e.requestId ? ` [request ${e.requestId}]` : ""}${e.docUrl ? ` See ${e.docUrl}` : ""}`
|
|
147
|
+
: e instanceof z.ZodError ? `validation_failed: ${e.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}`
|
|
148
|
+
: String(e instanceof Error ? e.message : e);
|
|
149
|
+
return { isError: true, content: [{ type: "text", text }] };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Title and hints of every tool (MCP tool annotations; required by Claude's connectors directory):
|
|
154
|
+
* read-only tools can run without asking, and publishing or cancelling is flagged so clients confirm first.
|
|
155
|
+
*/
|
|
156
|
+
export const TOOL_META = {
|
|
157
|
+
list_profiles: { title: "List profiles", annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
158
|
+
create_profile: { title: "Create a profile", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } },
|
|
159
|
+
connect: { title: "Get a link to connect an account", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } },
|
|
160
|
+
list_accounts: { title: "List connected accounts", annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
161
|
+
publish_options: { title: "Get a network's posting options", annotations: { readOnlyHint: true, openWorldHint: true } },
|
|
162
|
+
upload_media: { title: "Upload a local file", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } },
|
|
163
|
+
validate_post: { title: "Check a post without publishing", annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
164
|
+
create_post: { title: "Publish or schedule a post", annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true } },
|
|
165
|
+
get_post: { title: "Get a post's status", annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
166
|
+
list_posts: { title: "List recent posts", annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
167
|
+
cancel_post: { title: "Cancel a scheduled post", annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false } },
|
|
168
|
+
};
|
|
169
|
+
/** Registers the tools on an McpServer with their titles and annotations (local stdio server and the remote /mcp) */
|
|
170
|
+
export function registerTools(server, tools) {
|
|
171
|
+
const s = server;
|
|
172
|
+
for (const t of tools) {
|
|
173
|
+
const meta = TOOL_META[t.name];
|
|
174
|
+
if (!meta)
|
|
175
|
+
throw new Error(`Tool ${t.name} has no title and annotations in TOOL_META`);
|
|
176
|
+
s.registerTool(t.name, { title: meta.title, description: t.description, inputSchema: t.schema, annotations: { title: meta.title, ...meta.annotations } }, (args) => runTool(t, args));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=tools.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiwings/mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "MCP server for APIWings: connect accounts, upload media, publish and read posts",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"apiwings",
|
|
7
|
+
"mcp",
|
|
8
|
+
"model context protocol",
|
|
9
|
+
"claude",
|
|
10
|
+
"cursor",
|
|
11
|
+
"ai agents",
|
|
12
|
+
"social media"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "LV Tech Labs, S.L.U. (APIWings) <support@apiwings.com>",
|
|
16
|
+
"homepage": "https://apiwings.com/docs",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"email": "support@apiwings.com"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"bin": {
|
|
22
|
+
"apiwings-mcp": "dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"main": "dist/tools.js",
|
|
25
|
+
"types": "dist/tools.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**/*.js",
|
|
28
|
+
"dist/**/*.d.ts",
|
|
29
|
+
"README.md",
|
|
30
|
+
"LICENSE"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
40
|
+
"zod": "^3.23.0",
|
|
41
|
+
"@apiwings/sdk": "0.1.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@anthropic-ai/mcpb": "2.1.2",
|
|
45
|
+
"esbuild": "0.24.2"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -b",
|
|
49
|
+
"typecheck": "tsc -b",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"bundle:mcpb": "pnpm build && esbuild dist/index.js --bundle --platform=node --format=esm --target=node18 --outfile=mcpb/server/index.mjs --banner:js=\"import { createRequire } from 'module'; const require = createRequire(import.meta.url);\" && mcpb pack mcpb ../../apps/web/public/downloads/apiwings.mcpb"
|
|
52
|
+
}
|
|
6
53
|
}
|