@anaella/mcp 0.1.1 → 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.
@@ -2,9 +2,15 @@
2
2
 
3
3
  // src/config.ts
4
4
  function loadConfig(env) {
5
+ const apiUrl = env.ANAELLA_API_URL?.replace(/\/+$/, "") || "https://api.anaella.com";
5
6
  return {
6
7
  apiKey: env.ANAELLA_API_KEY,
7
- apiUrl: env.ANAELLA_API_URL?.replace(/\/+$/, "") || "https://api.anaella.com"
8
+ // Used for tool calls — internal Docker host in prod (http://anaella-api:3333).
9
+ apiUrl,
10
+ // Advertised to MCP clients in the 401 WWW-Authenticate pointer, so it must
11
+ // be publicly reachable. Falls back to apiUrl when not set (e.g. stdio users
12
+ // whose apiUrl is already their public URL).
13
+ publicApiUrl: env.ANAELLA_PUBLIC_API_URL?.replace(/\/+$/, "") || apiUrl
8
14
  };
9
15
  }
10
16
 
@@ -90,6 +96,39 @@ function buildTools(client) {
90
96
  inputSchema: { id: z.string() }
91
97
  },
92
98
  handler: wrap((args) => client.deletePost(args.id))
99
+ },
100
+ {
101
+ name: "get_analytics",
102
+ config: {
103
+ description: "Organization-wide analytics: overall totals plus a per-platform breakdown. Optional `period`: 24h | 7d | 30d | 90d | 1y (default 30d).",
104
+ inputSchema: {
105
+ period: z.enum(["24h", "7d", "30d", "90d", "1y"]).optional()
106
+ }
107
+ },
108
+ handler: wrap((args) => client.getAnalytics(args))
109
+ },
110
+ {
111
+ name: "get_post_analytics",
112
+ config: {
113
+ description: "Analytics for a single post by id: aggregate totals, growth vs the previous period, and history. Optional `period`: 24h | 7d | 30d | 90d | 1y.",
114
+ inputSchema: {
115
+ id: z.string().describe("Post id"),
116
+ period: z.enum(["24h", "7d", "30d", "90d", "1y"]).optional()
117
+ }
118
+ },
119
+ handler: wrap(
120
+ (args) => client.getPostAnalytics(args.id, { period: args.period })
121
+ )
122
+ },
123
+ {
124
+ name: "upload_media",
125
+ config: {
126
+ description: "Register public media URLs as reusable resources WITHOUT creating a post. Returns resource ids usable as create_post media ({ id }); each file downloads in the background.",
127
+ inputSchema: {
128
+ urls: z.array(z.string()).min(1).describe("Public media URLs to register")
129
+ }
130
+ },
131
+ handler: wrap((args) => client.uploadUrls(args.urls))
93
132
  }
94
133
  ];
95
134
  }
package/dist/http.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  buildServer,
4
4
  loadConfig
5
- } from "./chunk-AASEKJTS.js";
5
+ } from "./chunk-UVDX2Y2D.js";
6
6
 
7
7
  // src/http.ts
8
8
  import http from "http";
@@ -28,7 +28,7 @@ function sendJson(res, status, body) {
28
28
  res.writeHead(status, { "content-type": "application/json" });
29
29
  res.end(JSON.stringify(body));
30
30
  }
31
- function createHttpServer(apiUrl) {
31
+ function createHttpServer(apiUrl, publicApiUrl = apiUrl) {
32
32
  return http.createServer(async (req, res) => {
33
33
  const url = req.url ?? "";
34
34
  if (req.method === "GET" && url === "/health") {
@@ -42,9 +42,15 @@ function createHttpServer(apiUrl) {
42
42
  }
43
43
  const authz = req.headers.authorization ?? "";
44
44
  if (!/^Bearer\s+ana_/i.test(authz)) {
45
- sendJson(res, 401, {
46
- error: { code: "unauthorized", message: "Authorization: Bearer ana_\u2026 is required" }
45
+ res.writeHead(401, {
46
+ "content-type": "application/json",
47
+ "www-authenticate": `Bearer resource_metadata="${publicApiUrl.replace(/\/+$/, "")}/.well-known/oauth-protected-resource"`
47
48
  });
49
+ res.end(
50
+ JSON.stringify({
51
+ error: { code: "unauthorized", message: "Authorization: Bearer ana_\u2026 is required" }
52
+ })
53
+ );
48
54
  return;
49
55
  }
50
56
  const apiKey = authz.replace(/^Bearer\s+/i, "");
@@ -69,9 +75,9 @@ function createHttpServer(apiUrl) {
69
75
  });
70
76
  }
71
77
  function main() {
72
- const { apiUrl } = loadConfig(process.env);
78
+ const { apiUrl, publicApiUrl } = loadConfig(process.env);
73
79
  const port = Number(process.env.PORT) || 3e3;
74
- const server = createHttpServer(apiUrl);
80
+ const server = createHttpServer(apiUrl, publicApiUrl);
75
81
  server.listen(port, () => {
76
82
  process.stderr.write(`[anaella-mcp] HTTP server listening on :${port} \u2192 ${apiUrl}
77
83
  `);
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  buildServer,
4
4
  loadConfig
5
- } from "./chunk-AASEKJTS.js";
5
+ } from "./chunk-UVDX2Y2D.js";
6
6
 
7
7
  // src/index.ts
8
8
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@anaella/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for anaella.com — schedule and publish social posts via the /v1 API.",
5
5
  "type": "module",
6
- "bin": { "anaella-mcp": "dist/index.js" },
7
- "files": ["dist"],
8
- "publishConfig": { "access": "public" },
6
+ "bin": {
7
+ "anaella-mcp": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
9
15
  "scripts": {
10
16
  "build": "tsup",
11
17
  "prepublishOnly": "npm run build",
@@ -14,7 +20,7 @@
14
20
  "smoke": "bun run src/smoke.ts"
15
21
  },
16
22
  "dependencies": {
17
- "@anaella/client": "^0.1.0",
23
+ "@anaella/client": "^0.1.6",
18
24
  "@modelcontextprotocol/sdk": "^1.29.0",
19
25
  "zod": "^3.25.76"
20
26
  },