@anaella/mcp 0.1.0 → 0.1.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.
@@ -1,82 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // src/client.ts
4
- var AnaellaApiError = class extends Error {
5
- constructor(status, code, message, details) {
6
- super(message);
7
- this.status = status;
8
- this.code = code;
9
- this.details = details;
10
- this.name = "AnaellaApiError";
11
- }
12
- status;
13
- code;
14
- details;
15
- };
16
- var AnaellaClient = class {
17
- apiKey;
18
- baseUrl;
19
- constructor(opts) {
20
- this.apiKey = opts.apiKey;
21
- this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
22
- }
23
- async request(method, path, body) {
24
- let res;
25
- try {
26
- res = await fetch(this.baseUrl + path, {
27
- method,
28
- headers: {
29
- authorization: `Bearer ${this.apiKey}`,
30
- ...body === void 0 ? {} : { "content-type": "application/json" }
31
- },
32
- body: body === void 0 ? void 0 : JSON.stringify(body)
33
- });
34
- } catch (e) {
35
- throw new AnaellaApiError(
36
- 0,
37
- "network_error",
38
- `Could not reach anaella API: ${e.message}`
39
- );
40
- }
41
- const raw = await res.text();
42
- let json;
43
- try {
44
- json = raw ? JSON.parse(raw) : void 0;
45
- } catch {
46
- json = void 0;
47
- }
48
- if (!res.ok) {
49
- const env = json?.error;
50
- throw new AnaellaApiError(
51
- res.status,
52
- env?.code ?? "error",
53
- env?.message ?? `HTTP ${res.status}${raw ? `: ${raw.slice(0, 200)}` : ""}`,
54
- env?.details
55
- );
56
- }
57
- return json;
58
- }
59
- listChannels() {
60
- return this.request("GET", "/v1/channels");
61
- }
62
- createPost(body) {
63
- return this.request("POST", "/v1/posts", body);
64
- }
65
- listPosts(opts = {}) {
66
- const q = new URLSearchParams();
67
- if (opts.limit !== void 0) q.set("limit", String(opts.limit));
68
- if (opts.cursor !== void 0) q.set("cursor", String(opts.cursor));
69
- const qs = q.toString();
70
- return this.request("GET", `/v1/posts${qs ? `?${qs}` : ""}`);
71
- }
72
- getPost(id) {
73
- return this.request("GET", `/v1/posts/${encodeURIComponent(id)}`);
74
- }
75
- deletePost(id) {
76
- return this.request("DELETE", `/v1/posts/${encodeURIComponent(id)}`);
77
- }
78
- };
79
-
80
3
  // src/config.ts
81
4
  function loadConfig(env) {
82
5
  return {
@@ -90,6 +13,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
90
13
 
91
14
  // src/tools.ts
92
15
  import { z } from "zod";
16
+ import { AnaellaApiError } from "@anaella/client";
93
17
  var ok = (data) => ({
94
18
  content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
95
19
  });
@@ -98,7 +22,9 @@ var fail = (err) => {
98
22
  const detail = err.details?.length ? `
99
23
  Details: ${JSON.stringify(err.details)}` : "";
100
24
  return {
101
- content: [{ type: "text", text: `Error [${err.code}] (HTTP ${err.status}): ${err.message}${detail}` }],
25
+ content: [
26
+ { type: "text", text: `Error [${err.code}] (HTTP ${err.status}): ${err.message}${detail}` }
27
+ ],
102
28
  isError: true
103
29
  };
104
30
  }
@@ -134,7 +60,9 @@ function buildTools(client) {
134
60
  firstComment: z.string().max(2e3).optional()
135
61
  }
136
62
  },
137
- handler: wrap((args) => client.createPost(args))
63
+ handler: wrap(
64
+ (args) => client.createPost(args)
65
+ )
138
66
  },
139
67
  {
140
68
  name: "list_posts",
@@ -176,7 +104,6 @@ function buildServer(client) {
176
104
  }
177
105
 
178
106
  export {
179
- AnaellaClient,
180
107
  loadConfig,
181
108
  buildServer
182
109
  };
package/dist/http.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- AnaellaClient,
4
3
  buildServer,
5
4
  loadConfig
6
- } from "./chunk-GXJ2ADGM.js";
5
+ } from "./chunk-AASEKJTS.js";
7
6
 
8
7
  // src/http.ts
9
8
  import http from "http";
10
9
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
10
+ import { AnaellaClient } from "@anaella/client";
11
11
  function readBody(req) {
12
12
  return new Promise((resolve) => {
13
13
  const chunks = [];
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- AnaellaClient,
4
3
  buildServer,
5
4
  loadConfig
6
- } from "./chunk-GXJ2ADGM.js";
5
+ } from "./chunk-AASEKJTS.js";
7
6
 
8
7
  // src/index.ts
9
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
+ import { AnaellaClient } from "@anaella/client";
10
10
  async function main() {
11
11
  const { apiKey, apiUrl } = loadConfig(process.env);
12
12
  if (!apiKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anaella/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MCP server for anaella.com — schedule and publish social posts via the /v1 API.",
5
5
  "type": "module",
6
6
  "bin": { "anaella-mcp": "dist/index.js" },
@@ -14,6 +14,7 @@
14
14
  "smoke": "bun run src/smoke.ts"
15
15
  },
16
16
  "dependencies": {
17
+ "@anaella/client": "^0.1.0",
17
18
  "@modelcontextprotocol/sdk": "^1.29.0",
18
19
  "zod": "^3.25.76"
19
20
  },