@anaella/mcp 0.1.1 → 0.2.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Isaac Gounton
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.
@@ -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,15 @@
1
1
  {
2
2
  "name": "@anaella/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
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" },
6
+ "bin": {
7
+ "anaella-mcp": "dist/index.js"
8
+ },
7
9
  "files": ["dist"],
8
- "publishConfig": { "access": "public" },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
9
13
  "scripts": {
10
14
  "build": "tsup",
11
15
  "prepublishOnly": "npm run build",
@@ -14,13 +18,14 @@
14
18
  "smoke": "bun run src/smoke.ts"
15
19
  },
16
20
  "dependencies": {
17
- "@anaella/client": "^0.1.0",
21
+ "@anaella/client": "^0.1.7",
18
22
  "@modelcontextprotocol/sdk": "^1.29.0",
19
23
  "zod": "^3.25.76"
20
24
  },
21
25
  "devDependencies": {
26
+ "@types/node": "^22",
22
27
  "tsup": "^8.0.0",
23
- "typescript": "^5",
24
- "@types/node": "^22"
25
- }
28
+ "typescript": "^5"
29
+ },
30
+ "license": "MIT"
26
31
  }