@chirpie/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/dist/index.js +149 -0
- package/package.json +28 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
import { ChirpieClient, ChirpieApiError, getConfig } from "@chirpie/sdk";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var config = getConfig();
|
|
9
|
+
var client = config ? new ChirpieClient({ apiKey: config.api_key, baseUrl: config.base_url }) : null;
|
|
10
|
+
function requireClient() {
|
|
11
|
+
if (!client) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"Not authenticated. Run `chirpie login` or set CHIRPIE_API_KEY environment variable."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return client;
|
|
17
|
+
}
|
|
18
|
+
function formatResult(data) {
|
|
19
|
+
return {
|
|
20
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function formatError(err) {
|
|
24
|
+
const message = err instanceof ChirpieApiError ? `${err.code}: ${err.message}` : err instanceof Error ? err.message : "Unknown error";
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: message }],
|
|
27
|
+
isError: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var server = new McpServer({
|
|
31
|
+
name: "chirpie",
|
|
32
|
+
version: "0.1.0"
|
|
33
|
+
});
|
|
34
|
+
server.tool(
|
|
35
|
+
"chirpie_post",
|
|
36
|
+
"Create a post on X/Twitter. Posts immediately or at a scheduled time.",
|
|
37
|
+
{
|
|
38
|
+
account_id: z.string().describe("X account ID to post from"),
|
|
39
|
+
text: z.string().max(280).describe("Post text (max 280 chars)"),
|
|
40
|
+
schedule_at: z.string().optional().describe("ISO 8601 datetime to schedule the post")
|
|
41
|
+
},
|
|
42
|
+
async ({ account_id, text, schedule_at }) => {
|
|
43
|
+
try {
|
|
44
|
+
const result = await requireClient().createPost({ account_id, text, schedule_at });
|
|
45
|
+
return formatResult(result);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
return formatError(err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
server.tool(
|
|
52
|
+
"chirpie_thread",
|
|
53
|
+
"Create a thread (multiple posts) on X/Twitter.",
|
|
54
|
+
{
|
|
55
|
+
account_id: z.string().describe("X account ID to post from"),
|
|
56
|
+
posts: z.array(z.object({
|
|
57
|
+
text: z.string().max(280).describe("Post text")
|
|
58
|
+
})).min(2).max(25).describe("Array of posts in the thread"),
|
|
59
|
+
schedule_at: z.string().optional().describe("ISO 8601 datetime to schedule")
|
|
60
|
+
},
|
|
61
|
+
async ({ account_id, posts, schedule_at }) => {
|
|
62
|
+
try {
|
|
63
|
+
const result = await requireClient().createThread({ account_id, posts, schedule_at });
|
|
64
|
+
return formatResult(result);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
return formatError(err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
server.tool(
|
|
71
|
+
"chirpie_list_posts",
|
|
72
|
+
"List recent posts. Filter by status or account.",
|
|
73
|
+
{
|
|
74
|
+
status: z.string().optional().describe("Filter: draft, scheduled, published, failed"),
|
|
75
|
+
account_id: z.string().optional().describe("Filter by account ID"),
|
|
76
|
+
limit: z.number().optional().describe("Max results (default 20)")
|
|
77
|
+
},
|
|
78
|
+
async ({ status, account_id, limit }) => {
|
|
79
|
+
try {
|
|
80
|
+
const result = await requireClient().listPosts({ status, account_id, limit });
|
|
81
|
+
return formatResult(result);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
return formatError(err);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
server.tool(
|
|
88
|
+
"chirpie_get_post",
|
|
89
|
+
"Get a single post by ID.",
|
|
90
|
+
{
|
|
91
|
+
id: z.string().describe("Post ID")
|
|
92
|
+
},
|
|
93
|
+
async ({ id }) => {
|
|
94
|
+
try {
|
|
95
|
+
const result = await requireClient().getPost(id);
|
|
96
|
+
return formatResult(result);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return formatError(err);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
server.tool(
|
|
103
|
+
"chirpie_delete_post",
|
|
104
|
+
"Delete a post. Also deletes from X if published.",
|
|
105
|
+
{
|
|
106
|
+
id: z.string().describe("Post ID to delete")
|
|
107
|
+
},
|
|
108
|
+
async ({ id }) => {
|
|
109
|
+
try {
|
|
110
|
+
const result = await requireClient().deletePost(id);
|
|
111
|
+
return formatResult(result);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
return formatError(err);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
server.tool(
|
|
118
|
+
"chirpie_list_accounts",
|
|
119
|
+
"List connected X/Twitter accounts.",
|
|
120
|
+
{},
|
|
121
|
+
async () => {
|
|
122
|
+
try {
|
|
123
|
+
const result = await requireClient().listAccounts();
|
|
124
|
+
return formatResult(result);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
return formatError(err);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
server.tool(
|
|
131
|
+
"chirpie_analytics",
|
|
132
|
+
"Get analytics (impressions, likes, retweets, etc.) for a published post.",
|
|
133
|
+
{
|
|
134
|
+
post_id: z.string().describe("Post ID to get analytics for")
|
|
135
|
+
},
|
|
136
|
+
async ({ post_id }) => {
|
|
137
|
+
try {
|
|
138
|
+
const result = await requireClient().getPostAnalytics(post_id);
|
|
139
|
+
return formatResult(result);
|
|
140
|
+
} catch (err) {
|
|
141
|
+
return formatError(err);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
var transport = new StdioServerTransport();
|
|
146
|
+
server.connect(transport).catch((err) => {
|
|
147
|
+
console.error("Failed to start Chirpie MCP server:", err);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chirpie/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Chirpie MCP server — social media tools for AI agents",
|
|
5
|
+
"repository": { "type": "git", "url": "https://github.com/Firefloco/chirpie", "directory": "packages/mcp" },
|
|
6
|
+
"homepage": "https://chirpie.ai/docs/mcp",
|
|
7
|
+
"publishConfig": { "access": "public" },
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"chirpie-mcp": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist"],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"dev": "tsup --watch"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["chirpie", "mcp", "ai", "social-media", "claude"],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@chirpie/sdk": "^0.1.0",
|
|
21
|
+
"@modelcontextprotocol/sdk": "^1",
|
|
22
|
+
"zod": "^3.24.4"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"tsup": "^8",
|
|
26
|
+
"typescript": "^5"
|
|
27
|
+
}
|
|
28
|
+
}
|