bn-facebook-mcp-server 0.0.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.
Files changed (51) hide show
  1. package/README.md +245 -0
  2. package/dist/debug-middleware.d.ts +12 -0
  3. package/dist/debug-middleware.d.ts.map +1 -0
  4. package/dist/debug-middleware.js +36 -0
  5. package/dist/debug-middleware.js.map +1 -0
  6. package/dist/facebook-api-client.d.ts +68 -0
  7. package/dist/facebook-api-client.d.ts.map +1 -0
  8. package/dist/facebook-api-client.js +206 -0
  9. package/dist/facebook-api-client.js.map +1 -0
  10. package/dist/index.d.ts +9 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +132 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/schemas.d.ts +81 -0
  15. package/dist/schemas.d.ts.map +1 -0
  16. package/dist/schemas.js +170 -0
  17. package/dist/schemas.js.map +1 -0
  18. package/dist/tool-loader.d.ts +35 -0
  19. package/dist/tool-loader.d.ts.map +1 -0
  20. package/dist/tool-loader.js +125 -0
  21. package/dist/tool-loader.js.map +1 -0
  22. package/dist/tool-registry.d.ts +44 -0
  23. package/dist/tool-registry.d.ts.map +1 -0
  24. package/dist/tool-registry.js +54 -0
  25. package/dist/tool-registry.js.map +1 -0
  26. package/dist/tools/index.d.ts +5 -0
  27. package/dist/tools/index.d.ts.map +1 -0
  28. package/dist/tools/index.js +6 -0
  29. package/dist/tools/index.js.map +1 -0
  30. package/dist/tools/instagram.d.ts +9 -0
  31. package/dist/tools/instagram.d.ts.map +1 -0
  32. package/dist/tools/instagram.js +9 -0
  33. package/dist/tools/instagram.js.map +1 -0
  34. package/dist/tools/pages.d.ts +8 -0
  35. package/dist/tools/pages.d.ts.map +1 -0
  36. package/dist/tools/pages.js +8 -0
  37. package/dist/tools/pages.js.map +1 -0
  38. package/dist/tools/system.d.ts +7 -0
  39. package/dist/tools/system.d.ts.map +1 -0
  40. package/dist/tools/system.js +7 -0
  41. package/dist/tools/system.js.map +1 -0
  42. package/dist/tools/user.d.ts +105 -0
  43. package/dist/tools/user.d.ts.map +1 -0
  44. package/dist/tools/user.js +139 -0
  45. package/dist/tools/user.js.map +1 -0
  46. package/dist/types.d.ts +111 -0
  47. package/dist/types.d.ts.map +1 -0
  48. package/dist/types.js +5 -0
  49. package/dist/types.js.map +1 -0
  50. package/package.json +46 -0
  51. package/tools.json +108 -0
package/dist/index.js ADDED
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Facebook MCP Server
4
+ *
5
+ * A stateless Model Context Protocol server for Facebook Graph API
6
+ * using Bearer token authentication.
7
+ */
8
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
10
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
11
+ import express from "express";
12
+ import { z } from "zod";
13
+ // Import schemas
14
+ import { GetMeSchema, GetFriendsSchema, GetPhotosSchema, GetUserPostsSchema, GetVideosSchema, GetLikesSchema, GetPermissionsSchema, } from "./schemas.js";
15
+ // Import tool handlers
16
+ import { getMe, getFriends, getPhotos, getUserPosts, getVideos, getLikes, getPermissions, } from "./tools/index.js";
17
+ // Import tool loader
18
+ import { loadToolDefinitions } from "./tool-loader.js";
19
+ // Import tool registry
20
+ import { ToolRegistry } from "./tool-registry.js";
21
+ // Import debug mode flag
22
+ import { DEBUG_MODE } from "./debug-middleware.js";
23
+ // Create tool registry and register all tools
24
+ const toolRegistry = new ToolRegistry();
25
+ // Register User tools (7)
26
+ toolRegistry.register("get_me", GetMeSchema, getMe);
27
+ toolRegistry.register("get_friends", GetFriendsSchema, getFriends);
28
+ toolRegistry.register("get_photos", GetPhotosSchema, getPhotos);
29
+ toolRegistry.register("get_user_posts", GetUserPostsSchema, getUserPosts);
30
+ toolRegistry.register("get_videos", GetVideosSchema, getVideos);
31
+ toolRegistry.register("get_likes", GetLikesSchema, getLikes);
32
+ toolRegistry.register("get_permissions", GetPermissionsSchema, getPermissions);
33
+ // Create MCP server
34
+ const server = new Server({
35
+ name: "facebook-mcp-server",
36
+ version: "1.0.0",
37
+ }, {
38
+ capabilities: {
39
+ tools: {},
40
+ },
41
+ });
42
+ // Register tool handlers
43
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
44
+ // Load tool definitions from JSON (reloads on each request in dev mode)
45
+ const toolDefinitions = loadToolDefinitions();
46
+ return {
47
+ tools: toolDefinitions,
48
+ };
49
+ });
50
+ // Store current request in context (set during HTTP request handling)
51
+ let currentRequest = null;
52
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
53
+ if (!currentRequest) {
54
+ throw new Error("No request context available. This server must be called via HTTP transport.");
55
+ }
56
+ try {
57
+ // Execute tool via registry (includes automatic validation and debug wrapping)
58
+ const result = await toolRegistry.execute(request.params.name, request.params.arguments, currentRequest);
59
+ // Return formatted response with data and optional debug info
60
+ // Debug info is included in the response when DEBUG mode is enabled
61
+ return {
62
+ content: [
63
+ {
64
+ type: "text",
65
+ text: JSON.stringify(result, null, 2),
66
+ },
67
+ ],
68
+ };
69
+ }
70
+ catch (error) {
71
+ if (error instanceof z.ZodError) {
72
+ throw new Error(`Invalid arguments: ${error.message}`);
73
+ }
74
+ throw error;
75
+ }
76
+ });
77
+ // Create Express app with stateless HTTP transport
78
+ const app = express();
79
+ app.use(express.json());
80
+ // Create stateless transport (no session management)
81
+ const transport = new StreamableHTTPServerTransport({
82
+ sessionIdGenerator: undefined, // Stateless mode
83
+ enableJsonResponse: true,
84
+ });
85
+ // Connect server to transport
86
+ await server.connect(transport);
87
+ // Handle MCP requests
88
+ app.post("/mcp", async (req, res) => {
89
+ try {
90
+ // Store request in context for tool handlers to access headers
91
+ currentRequest = req;
92
+ await transport.handleRequest(req, res, req.body);
93
+ currentRequest = null; // Clear context after request
94
+ }
95
+ catch (error) {
96
+ currentRequest = null; // Clear context on error
97
+ console.error("Error handling MCP request:", error);
98
+ res.status(500).json({
99
+ error: "Internal server error",
100
+ message: error instanceof Error ? error.message : "Unknown error",
101
+ });
102
+ }
103
+ });
104
+ // Health check endpoint
105
+ app.get("/health", (_req, res) => {
106
+ res.json({
107
+ status: "healthy",
108
+ server: "facebook-mcp-server",
109
+ version: "1.0.0",
110
+ stateless: true,
111
+ debug: DEBUG_MODE,
112
+ registeredTools: toolRegistry.getToolNames(),
113
+ categories: {
114
+ user: 7,
115
+ },
116
+ });
117
+ });
118
+ // Start server
119
+ const PORT = process.env.PORT || 30003;
120
+ app.listen(PORT, () => {
121
+ console.log(`Facebook MCP Server running on http://localhost:${PORT}`);
122
+ console.log(`MCP endpoint: http://localhost:${PORT}/mcp`);
123
+ console.log(`Health check: http://localhost:${PORT}/health`);
124
+ console.log("Mode: Stateless (no session management)");
125
+ console.log("Authentication: Bearer token required");
126
+ console.log(`Debug mode: ${DEBUG_MODE ? "ENABLED" : "DISABLED"}`);
127
+ console.log(`Total tools: ${toolRegistry.getToolNames().length}`);
128
+ if (DEBUG_MODE) {
129
+ console.log(`Registered tools: ${toolRegistry.getToolNames().join(", ")}`);
130
+ }
131
+ });
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAA;AAClG,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,OAAyB,MAAM,SAAS,CAAA;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,cAAc,CAAA;AAErB,uB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AAO,CAAC,GAAG,CAAC,mDAAmD,IAAI,EAAE,CAAC,CAAA;IACtE,OAAO,CAAC,GAAG,CAAC,kCAAkC,IAAI,MAAM,CAAC,CAAA;IACzD,OAAO,CAAC,GAAG,CAAC,kCAAkC,IAAI,SAAS,CAAC,CAAA;IAC5D,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA;IACtD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAA;IACpD,OAAO,CAAC,GAAG,CAAC,eAAe,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAA;IACjE,OAAO,CAAC,GAAG,CAAC,gBAAgB,YAAY,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;IACjE,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,qBAAqB,YAAY,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC5E,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Zod schemas for Facebook/Instagram MCP Server tools
3
+ *
4
+ * Each schema includes comprehensive .describe() documentation for LLM-friendly usage.
5
+ * Descriptions include: use cases, examples, parameter relationships, and best practices.
6
+ */
7
+ import { z } from "zod";
8
+ export declare const GetMeSchema: z.ZodObject<{
9
+ fields: z.ZodOptional<z.ZodString>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ fields?: string | undefined;
12
+ }, {
13
+ fields?: string | undefined;
14
+ }>;
15
+ export declare const GetFriendsSchema: z.ZodObject<{
16
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
17
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
18
+ fields: z.ZodOptional<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ limit: number;
21
+ page: number;
22
+ fields?: string | undefined;
23
+ }, {
24
+ fields?: string | undefined;
25
+ limit?: number | undefined;
26
+ page?: number | undefined;
27
+ }>;
28
+ export declare const GetPhotosSchema: z.ZodObject<{
29
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
30
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
31
+ fields: z.ZodOptional<z.ZodString>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ limit: number;
34
+ page: number;
35
+ fields?: string | undefined;
36
+ }, {
37
+ fields?: string | undefined;
38
+ limit?: number | undefined;
39
+ page?: number | undefined;
40
+ }>;
41
+ export declare const GetUserPostsSchema: z.ZodObject<{
42
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
43
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
44
+ fields: z.ZodOptional<z.ZodString>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ limit: number;
47
+ page: number;
48
+ fields?: string | undefined;
49
+ }, {
50
+ fields?: string | undefined;
51
+ limit?: number | undefined;
52
+ page?: number | undefined;
53
+ }>;
54
+ export declare const GetVideosSchema: z.ZodObject<{
55
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
56
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
57
+ fields: z.ZodOptional<z.ZodString>;
58
+ }, "strip", z.ZodTypeAny, {
59
+ limit: number;
60
+ page: number;
61
+ fields?: string | undefined;
62
+ }, {
63
+ fields?: string | undefined;
64
+ limit?: number | undefined;
65
+ page?: number | undefined;
66
+ }>;
67
+ export declare const GetLikesSchema: z.ZodObject<{
68
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
69
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
70
+ fields: z.ZodOptional<z.ZodString>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ limit: number;
73
+ page: number;
74
+ fields?: string | undefined;
75
+ }, {
76
+ fields?: string | undefined;
77
+ limit?: number | undefined;
78
+ page?: number | undefined;
79
+ }>;
80
+ export declare const GetPermissionsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
81
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,WAAW;;;;;;EAyBtB,CAAA;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAkC3B,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;EA0B1B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EA2B7B,CAAA;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;EA2B1B,CAAA;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;EAyBzB,CAAA;AAEF,eAAO,MAAM,oBAAoB,gDAsBhC,CAAA"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Zod schemas for Facebook/Instagram MCP Server tools
3
+ *
4
+ * Each schema includes comprehensive .describe() documentation for LLM-friendly usage.
5
+ * Descriptions include: use cases, examples, parameter relationships, and best practices.
6
+ */
7
+ import { z } from "zod";
8
+ // ============================================================================
9
+ // User Tools (7)
10
+ // ============================================================================
11
+ export const GetMeSchema = z.object({
12
+ fields: z.string().optional().describe(`Comma-separated list of user profile fields to retrieve.
13
+
14
+ **Default Fields:**
15
+ - id - User's Facebook ID
16
+ - name - Full name
17
+ - email - Primary email (requires email permission)
18
+ - first_name, last_name - Name parts
19
+ - picture - Profile picture URL
20
+
21
+ **Additional Available Fields:**
22
+ - birthday - Birth date (if permissions allow)
23
+ - gender - Gender
24
+ - hometown - Hometown info
25
+ - location - Current city
26
+ - link - Profile URL
27
+
28
+ **Examples:**
29
+ - Default: "id,name,email,first_name,last_name,picture.width(200).height(200)"
30
+ - Minimal: "id,name"
31
+ - Full: "id,name,email,first_name,last_name,picture,birthday,gender"
32
+
33
+ **Note:** Some fields require additional permissions.`),
34
+ });
35
+ export const GetFriendsSchema = z.object({
36
+ page: z.number().optional().default(1).describe(`Page number to retrieve.
37
+
38
+ **Default:** 1
39
+ **Range:** 1 to unlimited
40
+
41
+ **Usage:**
42
+ - Page 1: First 25 friends (offset 0)
43
+ - Page 2: Next 25 friends (offset 25)
44
+ - Page 5: Friends 101-125 (offset 100)
45
+
46
+ **Example:**
47
+ First call: { page: 1, limit: 25 }
48
+ Next call: { page: 2, limit: 25 }`),
49
+ limit: z.number().optional().default(25).describe(`Maximum number of friends to retrieve per page.
50
+
51
+ **Default:** 25
52
+ **Range:** 1 to 100
53
+
54
+ **Note:** Only returns friends who also use the app.`),
55
+ fields: z.string().optional().describe(`Comma-separated list of friend fields.
56
+
57
+ **Default:** "id,name,picture"
58
+
59
+ **Available Fields:**
60
+ - id - Friend's Facebook ID
61
+ - name - Friend's name
62
+ - picture - Profile picture URL`),
63
+ });
64
+ export const GetPhotosSchema = z.object({
65
+ page: z.number().optional().default(1).describe(`Page number to retrieve.
66
+
67
+ **Default:** 1
68
+ **Range:** 1 to unlimited`),
69
+ limit: z.number().optional().default(25).describe(`Maximum number of photos to retrieve per page.
70
+
71
+ **Default:** 25
72
+ **Range:** 1 to 100`),
73
+ fields: z.string().optional().describe(`Comma-separated list of photo fields.
74
+
75
+ **Default:** "id,name,picture,created_time,link,images"
76
+
77
+ **Available Fields:**
78
+ - id - Photo ID
79
+ - name - Photo caption/name
80
+ - picture - Thumbnail URL
81
+ - created_time - When uploaded
82
+ - link - Photo URL
83
+ - images - Array of image sizes`),
84
+ });
85
+ export const GetUserPostsSchema = z.object({
86
+ page: z.number().optional().default(1).describe(`Page number to retrieve.
87
+
88
+ **Default:** 1
89
+ **Range:** 1 to unlimited`),
90
+ limit: z.number().optional().default(25).describe(`Maximum number of posts to retrieve per page.
91
+
92
+ **Default:** 25
93
+ **Range:** 1 to 100`),
94
+ fields: z.string().optional().describe(`Comma-separated list of post fields.
95
+
96
+ **Default:** "id,message,story,created_time,full_picture,permalink_url,shares,likes.summary(true),comments.summary(true)"
97
+
98
+ **Available Fields:**
99
+ - id - Post ID
100
+ - message - Post text
101
+ - story - Auto-generated story
102
+ - created_time - When posted
103
+ - full_picture - Image URL
104
+ - permalink_url - Post link
105
+ - shares, likes, comments - Engagement metrics`),
106
+ });
107
+ export const GetVideosSchema = z.object({
108
+ page: z.number().optional().default(1).describe(`Page number to retrieve.
109
+
110
+ **Default:** 1
111
+ **Range:** 1 to unlimited`),
112
+ limit: z.number().optional().default(25).describe(`Maximum number of videos to retrieve per page.
113
+
114
+ **Default:** 25
115
+ **Range:** 1 to 100`),
116
+ fields: z.string().optional().describe(`Comma-separated list of video fields.
117
+
118
+ **Default:** "id,title,description,created_time,permalink_url,thumbnails,length"
119
+
120
+ **Available Fields:**
121
+ - id - Video ID
122
+ - title - Video title
123
+ - description - Video description
124
+ - created_time - When uploaded
125
+ - permalink_url - Video link
126
+ - thumbnails - Thumbnail images
127
+ - length - Duration in seconds`),
128
+ });
129
+ export const GetLikesSchema = z.object({
130
+ page: z.number().optional().default(1).describe(`Page number to retrieve.
131
+
132
+ **Default:** 1
133
+ **Range:** 1 to unlimited`),
134
+ limit: z.number().optional().default(25).describe(`Maximum number of liked pages to retrieve per page.
135
+
136
+ **Default:** 25
137
+ **Range:** 1 to 100`),
138
+ fields: z.string().optional().describe(`Comma-separated list of page fields.
139
+
140
+ **Default:** "id,name,category,picture,fan_count"
141
+
142
+ **Available Fields:**
143
+ - id - Page ID
144
+ - name - Page name
145
+ - category - Page category
146
+ - picture - Page profile picture
147
+ - fan_count - Number of likes`),
148
+ });
149
+ export const GetPermissionsSchema = z.object({}).describe(`Get list of permissions granted to the current access token.
150
+
151
+ **No parameters required.**
152
+
153
+ **Returns:**
154
+ Array of permission objects:
155
+ - permission: Permission name (e.g., "email", "public_profile")
156
+ - status: "granted" or "declined"
157
+
158
+ **Use Cases:**
159
+ - Verify what data you can access
160
+ - Debug permission-related errors
161
+ - Check if user granted required permissions
162
+
163
+ **Common Permissions:**
164
+ - public_profile - Basic profile info (always granted)
165
+ - email - User's email address
166
+ - pages_show_list - List user's Pages
167
+ - pages_read_engagement - Read Page insights
168
+ - instagram_basic - Basic Instagram info
169
+ - instagram_content_publish - Post to Instagram`);
170
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACpC;;;;;;;;;;;;;;;;;;;;;sDAqBkD,CACnD;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAC7C;;;;;;;;;;;;kCAY8B,CAC/B;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAC/C;;;;;qDAKiD,CAClD;IACD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACpC;;;;;;;gCAO4B,CAC7B;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAC7C;;;0BAGsB,CACvB;IACD,K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AC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAC7C;;;0BAGsB,CACvB;IACD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAC/C;;;oBAGgB,CACjB;IACD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACpC;;;;;;;;;8BAS0B,CAC3B;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CACvD;;;;;;;;;;;;;;;;;;;;gDAoB8C,CAC/C,CAAA"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tool configuration loader
3
+ * Loads tool definitions from tools.json and validates them
4
+ *
5
+ * Supports loading from (in priority order):
6
+ * 1. Custom path via TOOLS_CONFIG_PATH environment variable
7
+ * 2. tools.json in current working directory (for development)
8
+ * 3. tools.json in package installation directory (for npx/installed usage)
9
+ */
10
+ export interface ToolDefinition {
11
+ name: string;
12
+ description: string;
13
+ inputSchema: {
14
+ type: string;
15
+ properties: Record<string, unknown>;
16
+ required?: string[];
17
+ };
18
+ }
19
+ export interface ToolsConfig {
20
+ [toolName: string]: ToolDefinition;
21
+ }
22
+ /**
23
+ * Load tool definitions from tools.json
24
+ * Uses caching in production, always reloads in development
25
+ */
26
+ export declare function loadToolDefinitions(forceReload?: boolean): ToolDefinition[];
27
+ /**
28
+ * Get a specific tool definition by name
29
+ */
30
+ export declare function getToolDefinition(toolName: string): ToolDefinition | undefined;
31
+ /**
32
+ * Clear the tool cache (useful for testing or forced reloads)
33
+ */
34
+ export declare function clearToolCache(): void;
35
+ //# sourceMappingURL=tool-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-loader.d.ts","sourceRoot":"","sources":["../src/tool-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACnC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;CACF;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAA;CACnC;AAmDD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,UAAQ,GAAG,cAAc,EAAE,CAsEzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG9E;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAIrC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Tool configuration loader
3
+ * Loads tool definitions from tools.json and validates them
4
+ *
5
+ * Supports loading from (in priority order):
6
+ * 1. Custom path via TOOLS_CONFIG_PATH environment variable
7
+ * 2. tools.json in current working directory (for development)
8
+ * 3. tools.json in package installation directory (for npx/installed usage)
9
+ */
10
+ import { readFileSync, existsSync } from "fs";
11
+ import { resolve, isAbsolute, dirname } from "path";
12
+ import { homedir } from "os";
13
+ import { fileURLToPath } from "url";
14
+ let cachedTools = null;
15
+ let lastLoadTime = 0;
16
+ let lastLoadPath = "";
17
+ /**
18
+ * Resolve the tools configuration file path
19
+ * Supports:
20
+ * - Environment variable: TOOLS_CONFIG_PATH
21
+ * - Absolute paths: /Users/username/Desktop/tools.json
22
+ * - Relative paths: ./tools.json, ../config/tools.json
23
+ * - Home directory: ~/Desktop/tools.json
24
+ * - Default: tools.json in current working directory
25
+ * - Fallback: tools.json in package installation directory
26
+ */
27
+ function resolveToolsPath() {
28
+ // Check environment variable first
29
+ const envPath = process.env.TOOLS_CONFIG_PATH;
30
+ if (envPath) {
31
+ // Expand ~ to home directory
32
+ const expandedPath = envPath.startsWith("~/")
33
+ ? resolve(homedir(), envPath.slice(2))
34
+ : envPath;
35
+ // If absolute path, use as-is
36
+ if (isAbsolute(expandedPath)) {
37
+ return expandedPath;
38
+ }
39
+ // Otherwise resolve relative to current working directory
40
+ return resolve(process.cwd(), expandedPath);
41
+ }
42
+ // Try current working directory first (for dev mode)
43
+ const cwdPath = resolve(process.cwd(), "tools.json");
44
+ if (existsSync(cwdPath)) {
45
+ return cwdPath;
46
+ }
47
+ // Fallback: tools.json in package installation directory (for npx/installed usage)
48
+ // Get the directory of this module file
49
+ const moduleDir = dirname(fileURLToPath(import.meta.url));
50
+ // Go up from dist/tool-loader.js to package root
51
+ const packageRoot = resolve(moduleDir, "..");
52
+ const packagePath = resolve(packageRoot, "tools.json");
53
+ return packagePath;
54
+ }
55
+ /**
56
+ * Load tool definitions from tools.json
57
+ * Uses caching in production, always reloads in development
58
+ */
59
+ export function loadToolDefinitions(forceReload = false) {
60
+ const isDev = process.env.NODE_ENV !== "production";
61
+ const now = Date.now();
62
+ // Get the tools config path
63
+ const toolsPath = resolveToolsPath();
64
+ // In production, cache tools and only reload if forced or path changed
65
+ // In development, reload every time (for nodemon compatibility)
66
+ if (!isDev &&
67
+ !forceReload &&
68
+ cachedTools &&
69
+ now - lastLoadTime < 60000 &&
70
+ lastLoadPath === toolsPath) {
71
+ return cachedTools;
72
+ }
73
+ try {
74
+ // Check if file exists
75
+ if (!existsSync(toolsPath)) {
76
+ throw new Error(`Tools configuration file not found: ${toolsPath}`);
77
+ }
78
+ const toolsJson = readFileSync(toolsPath, "utf-8");
79
+ const toolsConfig = JSON.parse(toolsJson);
80
+ // Convert config object to array of tool definitions
81
+ const tools = Object.values(toolsConfig);
82
+ // Validate tool definitions
83
+ for (const tool of tools) {
84
+ if (!tool.name || !tool.description || !tool.inputSchema) {
85
+ throw new Error(`Invalid tool definition: ${JSON.stringify(tool)}`);
86
+ }
87
+ }
88
+ cachedTools = tools;
89
+ lastLoadTime = now;
90
+ lastLoadPath = toolsPath;
91
+ console.log(`[Tool Loader] Loaded ${tools.length} tool definitions from: ${toolsPath}`);
92
+ if (isDev) {
93
+ console.log(`[Tool Loader] Development mode: tools will be reloaded on server restart`);
94
+ }
95
+ if (process.env.TOOLS_CONFIG_PATH) {
96
+ console.log(`[Tool Loader] Using custom config path from TOOLS_CONFIG_PATH`);
97
+ }
98
+ return tools;
99
+ }
100
+ catch (error) {
101
+ console.error("[Tool Loader] Error loading tools.json:", error);
102
+ // In case of error, return cached tools if available
103
+ if (cachedTools) {
104
+ console.warn("[Tool Loader] Using cached tool definitions due to load error");
105
+ return cachedTools;
106
+ }
107
+ throw new Error(`Failed to load tool definitions: ${error instanceof Error ? error.message : "Unknown error"}`);
108
+ }
109
+ }
110
+ /**
111
+ * Get a specific tool definition by name
112
+ */
113
+ export function getToolDefinition(toolName) {
114
+ const tools = loadToolDefinitions();
115
+ return tools.find((tool) => tool.name === toolName);
116
+ }
117
+ /**
118
+ * Clear the tool cache (useful for testing or forced reloads)
119
+ */
120
+ export function clearToolCache() {
121
+ cachedTools = null;
122
+ lastLoadTime = 0;
123
+ console.log("[Tool Loader] Tool cache cleared");
124
+ }
125
+ //# sourceMappingURL=tool-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-loader.js","sourceRoot":"","sources":["../src/tool-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAgBnC,IAAI,WAAW,GAA4B,IAAI,CAAA;AAC/C,IAAI,YAAY,GAAG,CAAC,CAAA;AACpB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AAG,CAAC,iBAAiB,EAAE,CAAC;YAClC,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAA;QAE/D,qDAAqD;QACrD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CACV,+DAA+D,CAChE,CAAA;YACD,OAAO,WAAW,CAAA;QACpB,CAAC;QAED,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAC/F,CAAA;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,MAAM,KAAK,GAAG,mBAAmB,EAAE,CAAA;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAA;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,WAAW,GAAG,IAAI,CAAA;IAClB,YAAY,GAAG,CAAC,CAAA;IAChB,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;AACjD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { Request } from "express";
2
+ import type { z } from "zod";
3
+ import type { ToolResponse } from "./types.js";
4
+ type ToolHandler = (req: Request, args: unknown) => Promise<unknown>;
5
+ type ToolSchema = z.ZodSchema<unknown>;
6
+ /**
7
+ * Registry for managing and executing MCP tools with automatic debug wrapping
8
+ */
9
+ export declare class ToolRegistry {
10
+ private tools;
11
+ /**
12
+ * Register a new tool in the registry
13
+ *
14
+ * @param name - Unique name of the tool
15
+ * @param schema - Zod schema for validating tool input
16
+ * @param handler - Async function that executes the tool logic
17
+ */
18
+ register(name: string, schema: ToolSchema, handler: ToolHandler): void;
19
+ /**
20
+ * Execute a tool by name with automatic validation and debug wrapping
21
+ *
22
+ * @param toolName - Name of the tool to execute
23
+ * @param rawInput - Raw input arguments (will be validated against schema)
24
+ * @param req - Express request object for accessing headers/context
25
+ * @returns ToolResponse with data and optional debug metadata
26
+ * @throws Error if tool is not found or validation fails
27
+ */
28
+ execute(toolName: string, rawInput: unknown, req: Request): Promise<ToolResponse<unknown>>;
29
+ /**
30
+ * Check if a tool exists in the registry
31
+ *
32
+ * @param toolName - Name of the tool to check
33
+ * @returns True if the tool is registered
34
+ */
35
+ has(toolName: string): boolean;
36
+ /**
37
+ * Get all registered tool names
38
+ *
39
+ * @returns Array of registered tool names
40
+ */
41
+ getToolNames(): string[];
42
+ }
43
+ export {};
44
+ //# sourceMappingURL=tool-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-registry.d.ts","sourceRoot":"","sources":["../src/tool-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAI9C,KAAK,WAAW,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AACpE,KAAK,UAAU,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAWtC;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAoC;IAEjD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAItE;;;;;;;;OAQG;IACG,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAcjC;;;;;OAKG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B;;;;OAIG;IACH,YAAY,IAAI,MAAM,EAAE;CAGzB"}