sopo-mcp 1.0.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/.dockerignore +10 -0
- package/.env +7 -0
- package/.ghaymah.json +20 -0
- package/Dockerfile +37 -0
- package/GUIDE.md +311 -0
- package/README.md +143 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +94 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/sopo.prompts.d.ts +8 -0
- package/dist/prompts/sopo.prompts.d.ts.map +1 -0
- package/dist/prompts/sopo.prompts.js +102 -0
- package/dist/prompts/sopo.prompts.js.map +1 -0
- package/dist/resources/platform.resources.d.ts +9 -0
- package/dist/resources/platform.resources.d.ts.map +1 -0
- package/dist/resources/platform.resources.js +143 -0
- package/dist/resources/platform.resources.js.map +1 -0
- package/dist/sopo-client.d.ts +51 -0
- package/dist/sopo-client.d.ts.map +1 -0
- package/dist/sopo-client.js +145 -0
- package/dist/sopo-client.js.map +1 -0
- package/dist/tools/aggregate-request.tools.d.ts +8 -0
- package/dist/tools/aggregate-request.tools.d.ts.map +1 -0
- package/dist/tools/aggregate-request.tools.js +57 -0
- package/dist/tools/aggregate-request.tools.js.map +1 -0
- package/dist/tools/auth.tools.d.ts +12 -0
- package/dist/tools/auth.tools.d.ts.map +1 -0
- package/dist/tools/auth.tools.js +152 -0
- package/dist/tools/auth.tools.js.map +1 -0
- package/dist/tools/collection.tools.d.ts +8 -0
- package/dist/tools/collection.tools.d.ts.map +1 -0
- package/dist/tools/collection.tools.js +54 -0
- package/dist/tools/collection.tools.js.map +1 -0
- package/dist/tools/gateway-plugin.tools.d.ts +8 -0
- package/dist/tools/gateway-plugin.tools.d.ts.map +1 -0
- package/dist/tools/gateway-plugin.tools.js +64 -0
- package/dist/tools/gateway-plugin.tools.js.map +1 -0
- package/dist/tools/gateway-route.tools.d.ts +8 -0
- package/dist/tools/gateway-route.tools.d.ts.map +1 -0
- package/dist/tools/gateway-route.tools.js +68 -0
- package/dist/tools/gateway-route.tools.js.map +1 -0
- package/dist/tools/gateway.tools.d.ts +8 -0
- package/dist/tools/gateway.tools.d.ts.map +1 -0
- package/dist/tools/gateway.tools.js +56 -0
- package/dist/tools/gateway.tools.js.map +1 -0
- package/dist/tools/observability.tools.d.ts +9 -0
- package/dist/tools/observability.tools.d.ts.map +1 -0
- package/dist/tools/observability.tools.js +54 -0
- package/dist/tools/observability.tools.js.map +1 -0
- package/dist/tools/service-target.tools.d.ts +8 -0
- package/dist/tools/service-target.tools.d.ts.map +1 -0
- package/dist/tools/service-target.tools.js +52 -0
- package/dist/tools/service-target.tools.js.map +1 -0
- package/dist/tools/service.tools.d.ts +8 -0
- package/dist/tools/service.tools.d.ts.map +1 -0
- package/dist/tools/service.tools.js +67 -0
- package/dist/tools/service.tools.js.map +1 -0
- package/dist/tools/user-profile.tools.d.ts +8 -0
- package/dist/tools/user-profile.tools.d.ts.map +1 -0
- package/dist/tools/user-profile.tools.js +46 -0
- package/dist/tools/user-profile.tools.js.map +1 -0
- package/package.json +33 -0
- package/src/index.ts +115 -0
- package/src/prompts/sopo.prompts.ts +128 -0
- package/src/resources/platform.resources.ts +163 -0
- package/src/sopo-client.ts +180 -0
- package/src/tools/aggregate-request.tools.ts +83 -0
- package/src/tools/auth.tools.ts +187 -0
- package/src/tools/collection.tools.ts +80 -0
- package/src/tools/gateway-plugin.tools.ts +90 -0
- package/src/tools/gateway-route.tools.ts +94 -0
- package/src/tools/gateway.tools.ts +82 -0
- package/src/tools/observability.tools.ts +87 -0
- package/src/tools/service-target.tools.ts +78 -0
- package/src/tools/service.tools.ts +93 -0
- package/src/tools/user-profile.tools.ts +72 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Authentication Tools
|
|
3
|
+
*
|
|
4
|
+
* Provides login and token refresh capabilities so the AI can
|
|
5
|
+
* authenticate automatically without requiring manual token setup.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { getBackendUrl, updateAccessToken, setRefreshToken, getRefreshToken, } from '../sopo-client.js';
|
|
9
|
+
/**
|
|
10
|
+
* Registers authentication tools on the MCP server.
|
|
11
|
+
*/
|
|
12
|
+
export function registerAuthTools(server) {
|
|
13
|
+
// ── Login with Email & Password ──────────────────────────────
|
|
14
|
+
server.tool('sopo_login', 'Sign in to Sopo with email and password. On success, the access token is automatically configured for all subsequent API calls. You do NOT need to set any token manually after this.', {
|
|
15
|
+
email: z.string().email().describe('User email address'),
|
|
16
|
+
password: z.string().min(1).describe('User password'),
|
|
17
|
+
}, async ({ email, password }) => {
|
|
18
|
+
try {
|
|
19
|
+
const backendUrl = getBackendUrl();
|
|
20
|
+
const response = await fetch(`${backendUrl}/auth/signin/email-password`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: { 'Content-Type': 'application/json' },
|
|
23
|
+
body: JSON.stringify({ email, password }),
|
|
24
|
+
});
|
|
25
|
+
const body = await response.json().catch(() => null);
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
const errorMsg = body?.error?.message || body?.message || `HTTP ${response.status}`;
|
|
28
|
+
return {
|
|
29
|
+
content: [{ type: 'text', text: `❌ Login failed: ${errorMsg}` }],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Extract access token from response
|
|
33
|
+
const accessToken = body?.session?.accessToken;
|
|
34
|
+
if (!accessToken) {
|
|
35
|
+
return {
|
|
36
|
+
content: [{ type: 'text', text: '❌ Login succeeded but no access token was returned. Response: ' + JSON.stringify(body) }],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Update the client with the new access token
|
|
40
|
+
updateAccessToken(accessToken);
|
|
41
|
+
// Try to extract refresh token from response body or Set-Cookie header
|
|
42
|
+
const refreshTokenFromBody = body?.session?.refreshToken;
|
|
43
|
+
const setCookieHeader = response.headers.get('set-cookie');
|
|
44
|
+
let refreshTokenValue = refreshTokenFromBody;
|
|
45
|
+
if (!refreshTokenValue && setCookieHeader) {
|
|
46
|
+
// Parse sopo_refresh_token from Set-Cookie header
|
|
47
|
+
const match = setCookieHeader.match(/sopo_refresh_token=([^;]+)/);
|
|
48
|
+
if (match) {
|
|
49
|
+
refreshTokenValue = match[1];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (refreshTokenValue) {
|
|
53
|
+
setRefreshToken(refreshTokenValue);
|
|
54
|
+
}
|
|
55
|
+
const userName = body?.session?.user?.displayName || body?.session?.user?.email || email;
|
|
56
|
+
const expiresIn = body?.session?.accessTokenExpiresIn;
|
|
57
|
+
const hasRefresh = !!refreshTokenValue;
|
|
58
|
+
return {
|
|
59
|
+
content: [{
|
|
60
|
+
type: 'text',
|
|
61
|
+
text: `✅ Login successful!\n\n` +
|
|
62
|
+
`👤 User: ${userName}\n` +
|
|
63
|
+
`🔑 Access Token: configured automatically\n` +
|
|
64
|
+
`⏱️ Expires in: ${expiresIn ? `${expiresIn} seconds` : 'unknown'}\n` +
|
|
65
|
+
`🔄 Refresh Token: ${hasRefresh ? 'stored (auto-refresh available)' : 'not available (login again when token expires)'}\n\n` +
|
|
66
|
+
`All API calls will now use this session. You can start managing gateways, services, and routes.`,
|
|
67
|
+
}],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
return {
|
|
72
|
+
content: [{ type: 'text', text: `❌ Login error: ${err.message || 'Network error'}` }],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// ── Refresh Access Token ─────────────────────────────────────
|
|
77
|
+
server.tool('sopo_refresh_token', 'Refresh the current access token using the stored refresh token. Call this when API calls start returning 401 Unauthorized errors. The new access token is automatically configured.', {}, async () => {
|
|
78
|
+
try {
|
|
79
|
+
const currentRefreshToken = getRefreshToken();
|
|
80
|
+
if (!currentRefreshToken) {
|
|
81
|
+
return {
|
|
82
|
+
content: [{
|
|
83
|
+
type: 'text',
|
|
84
|
+
text: '❌ No refresh token available. Please use `sopo_login` to sign in first.',
|
|
85
|
+
}],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const backendUrl = getBackendUrl();
|
|
89
|
+
const response = await fetch(`${backendUrl}/auth/token`, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: { 'Content-Type': 'application/json' },
|
|
92
|
+
body: JSON.stringify({ refreshToken: currentRefreshToken }),
|
|
93
|
+
});
|
|
94
|
+
const body = await response.json().catch(() => null);
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
const errorMsg = body?.error?.message || body?.message || `HTTP ${response.status}`;
|
|
97
|
+
// Clear the stored refresh token since it's invalid
|
|
98
|
+
setRefreshToken('');
|
|
99
|
+
return {
|
|
100
|
+
content: [{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: `❌ Token refresh failed: ${errorMsg}\n\nPlease use \`sopo_login\` to sign in again.`,
|
|
103
|
+
}],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// Extract new access token
|
|
107
|
+
const accessToken = body?.session?.accessToken || body?.accessToken;
|
|
108
|
+
if (!accessToken) {
|
|
109
|
+
return {
|
|
110
|
+
content: [{
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: '❌ Token refresh succeeded but no access token was returned. Response: ' + JSON.stringify(body),
|
|
113
|
+
}],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// Update the client with the new access token
|
|
117
|
+
updateAccessToken(accessToken);
|
|
118
|
+
// Update refresh token if a new one was provided
|
|
119
|
+
const newRefreshToken = body?.session?.refreshToken || body?.refreshToken;
|
|
120
|
+
const setCookieHeader = response.headers.get('set-cookie');
|
|
121
|
+
if (newRefreshToken) {
|
|
122
|
+
setRefreshToken(newRefreshToken);
|
|
123
|
+
}
|
|
124
|
+
else if (setCookieHeader) {
|
|
125
|
+
const match = setCookieHeader.match(/sopo_refresh_token=([^;]+)/);
|
|
126
|
+
if (match) {
|
|
127
|
+
setRefreshToken(match[1]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const expiresIn = body?.session?.accessTokenExpiresIn || body?.accessTokenExpiresIn;
|
|
131
|
+
return {
|
|
132
|
+
content: [{
|
|
133
|
+
type: 'text',
|
|
134
|
+
text: `✅ Token refreshed successfully!\n\n` +
|
|
135
|
+
`🔑 New Access Token: configured automatically\n` +
|
|
136
|
+
`⏱️ Expires in: ${expiresIn ? `${expiresIn} seconds` : 'unknown'}\n` +
|
|
137
|
+
`🔄 Refresh Token: updated\n\n` +
|
|
138
|
+
`All API calls will now use the new token.`,
|
|
139
|
+
}],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
return {
|
|
144
|
+
content: [{
|
|
145
|
+
type: 'text',
|
|
146
|
+
text: `❌ Token refresh error: ${err.message || 'Network error'}`,
|
|
147
|
+
}],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=auth.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.tools.js","sourceRoot":"","sources":["../../src/tools/auth.tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAEjD,gEAAgE;IAChE,MAAM,CAAC,IAAI,CACT,YAAY,EACZ,uLAAuL,EACvL;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;QACxD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;KACtD,EACD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,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Collection Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Collections (organizational groups for routes/services in Pro mode).
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export declare function registerCollectionTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=collection.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.tools.d.ts","sourceRoot":"","sources":["../../src/tools/collection.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAqE/D"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Collection Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Collections (organizational groups for routes/services in Pro mode).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { sopoGet, sopoPost, sopoPatch, sopoDelete } from '../sopo-client.js';
|
|
8
|
+
export function registerCollectionTools(server) {
|
|
9
|
+
// ── List Collections ──────────────────────────────────────────
|
|
10
|
+
server.tool('list_collections', 'List all collections (organizational groupings for Pro mode gateways). Returns id, gateway_id, name, and description.', {}, async () => {
|
|
11
|
+
const result = await sopoGet('/api/v1/collections');
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
16
|
+
});
|
|
17
|
+
// ── Create Collection ─────────────────────────────────────────
|
|
18
|
+
server.tool('create_collection', 'Create a new collection inside a gateway (Pro mode). Requires gateway_id and name.', {
|
|
19
|
+
gateway_id: z.string().uuid().describe('UUID of the parent gateway (must exist)'),
|
|
20
|
+
name: z.string().describe('Collection name (e.g. "v1", "auth-apis")'),
|
|
21
|
+
description: z.string().optional().describe('Description of the collection'),
|
|
22
|
+
}, async (args) => {
|
|
23
|
+
const result = await sopoPost('/api/v1/collections', args);
|
|
24
|
+
if (!result.success) {
|
|
25
|
+
return { content: [{ type: 'text', text: `Error creating collection: ${result.error}` }], isError: true };
|
|
26
|
+
}
|
|
27
|
+
return { content: [{ type: 'text', text: `Collection created:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
28
|
+
});
|
|
29
|
+
// ── Update Collection ─────────────────────────────────────────
|
|
30
|
+
server.tool('update_collection', 'Update a collection by UUID. You can change name, description, or is_active.', {
|
|
31
|
+
id: z.string().uuid().describe('UUID of the collection'),
|
|
32
|
+
name: z.string().optional().describe('New name'),
|
|
33
|
+
description: z.string().optional().describe('New description'),
|
|
34
|
+
is_active: z.boolean().optional().describe('Active status'),
|
|
35
|
+
}, async (args) => {
|
|
36
|
+
const { id, ...body } = args;
|
|
37
|
+
const result = await sopoPatch(`/api/v1/collections/${id}`, body);
|
|
38
|
+
if (!result.success) {
|
|
39
|
+
return { content: [{ type: 'text', text: `Error updating collection: ${result.error}` }], isError: true };
|
|
40
|
+
}
|
|
41
|
+
return { content: [{ type: 'text', text: `Collection updated:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
42
|
+
});
|
|
43
|
+
// ── Delete Collection ─────────────────────────────────────────
|
|
44
|
+
server.tool('delete_collection', 'Delete a collection by its UUID.', {
|
|
45
|
+
id: z.string().uuid().describe('UUID of the collection to delete'),
|
|
46
|
+
}, async (args) => {
|
|
47
|
+
const result = await sopoDelete(`/api/v1/collections/${args.id}`);
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
return { content: [{ type: 'text', text: `Error deleting collection: ${result.error}` }], isError: true };
|
|
50
|
+
}
|
|
51
|
+
return { content: [{ type: 'text', text: `Collection deleted successfully.` }] };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=collection.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.tools.js","sourceRoot":"","sources":["../../src/tools/collection.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7E,MAAM,UAAU,uBAAuB,CAAC,MAAiB;IAEvD,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,uHAAuH,EACvH,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxF,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;IAEF,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,mBAAmB,EACnB,oFAAoF,EACpF;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;QACjF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;QACrE,WAAW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
|
4
|
+
* CRUD tools for managing Gateway Plugins (middleware like API Key auth, rate limiting, etc.).
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export declare function registerGatewayPluginTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=gateway-plugin.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-plugin.tools.d.ts","sourceRoot":"","sources":["../../src/tools/gateway-plugin.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+ElE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Gateway Plugin Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Gateway Plugins (middleware like API Key auth, rate limiting, etc.).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { sopoGet, sopoPost, sopoPatch, sopoDelete } from '../sopo-client.js';
|
|
8
|
+
export function registerGatewayPluginTools(server) {
|
|
9
|
+
// ── List Gateway Plugins ──────────────────────────────────────
|
|
10
|
+
server.tool('list_gateway_plugins', 'List all gateway plugins (middleware). Returns id, name, phase, gateway_id or route_id, enabled status, and plugin_config.', {}, async () => {
|
|
11
|
+
const result = await sopoGet('/api/v1/gateway-plugins');
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
16
|
+
});
|
|
17
|
+
// ── Create Gateway Plugin ─────────────────────────────────────
|
|
18
|
+
server.tool('create_gateway_plugin', 'Attach a middleware plugin to a gateway or a specific route. IMPORTANT: You must provide EITHER gateway_id OR route_id, NOT both (mutually exclusive).', {
|
|
19
|
+
name: z.string().describe('Plugin name (e.g. "apikey", "rate_limit", "cors")'),
|
|
20
|
+
phase: z.string().describe('Execution phase: "access", "header_filter", "body_filter", or "log"'),
|
|
21
|
+
gateway_id: z.string().uuid().optional().describe('Attach to this gateway (mutually exclusive with route_id)'),
|
|
22
|
+
route_id: z.string().uuid().optional().describe('Attach to this route (mutually exclusive with gateway_id)'),
|
|
23
|
+
plugin_config: z.record(z.any()).optional().describe('Plugin configuration object (JSON)'),
|
|
24
|
+
enabled: z.boolean().optional().default(true).describe('Whether the plugin is enabled'),
|
|
25
|
+
fail_open: z.boolean().optional().default(false).describe('If true, requests pass even if plugin fails'),
|
|
26
|
+
sort_order: z.number().optional().default(0).describe('Execution order (lower = earlier)'),
|
|
27
|
+
}, async (args) => {
|
|
28
|
+
const result = await sopoPost('/api/v1/gateway-plugins', args);
|
|
29
|
+
if (!result.success) {
|
|
30
|
+
return { content: [{ type: 'text', text: `Error creating plugin: ${result.error}` }], isError: true };
|
|
31
|
+
}
|
|
32
|
+
return { content: [{ type: 'text', text: `Gateway plugin created:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
33
|
+
});
|
|
34
|
+
// ── Update Gateway Plugin ─────────────────────────────────────
|
|
35
|
+
server.tool('update_gateway_plugin', 'Update an existing gateway plugin. You can change name, phase, enabled status, config, or move it to a different gateway/route.', {
|
|
36
|
+
id: z.string().uuid().describe('UUID of the plugin to update'),
|
|
37
|
+
name: z.string().optional().describe('New plugin name'),
|
|
38
|
+
phase: z.string().optional().describe('New phase'),
|
|
39
|
+
gateway_id: z.string().uuid().optional().describe('Move to this gateway'),
|
|
40
|
+
route_id: z.string().uuid().optional().describe('Move to this route'),
|
|
41
|
+
plugin_config: z.record(z.any()).optional().describe('New plugin config'),
|
|
42
|
+
enabled: z.boolean().optional().describe('Enable/disable'),
|
|
43
|
+
fail_open: z.boolean().optional().describe('Fail open setting'),
|
|
44
|
+
sort_order: z.number().optional().describe('Execution order'),
|
|
45
|
+
}, async (args) => {
|
|
46
|
+
const { id, ...body } = args;
|
|
47
|
+
const result = await sopoPatch(`/api/v1/gateway-plugins/${id}`, body);
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
return { content: [{ type: 'text', text: `Error updating plugin: ${result.error}` }], isError: true };
|
|
50
|
+
}
|
|
51
|
+
return { content: [{ type: 'text', text: `Gateway plugin updated:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
52
|
+
});
|
|
53
|
+
// ── Delete Gateway Plugin ─────────────────────────────────────
|
|
54
|
+
server.tool('delete_gateway_plugin', 'Delete a gateway plugin by its UUID.', {
|
|
55
|
+
id: z.string().uuid().describe('UUID of the plugin to delete'),
|
|
56
|
+
}, async (args) => {
|
|
57
|
+
const result = await sopoDelete(`/api/v1/gateway-plugins/${args.id}`);
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
return { content: [{ type: 'text', text: `Error deleting plugin: ${result.error}` }], isError: true };
|
|
60
|
+
}
|
|
61
|
+
return { content: [{ type: 'text', text: `Gateway plugin deleted successfully.` }] };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=gateway-plugin.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-plugin.tools.js","sourceRoot":"","sources":["../../src/tools/gateway-plugin.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7E,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAE1D,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,4HAA4H,EAC5H,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,yBAAyB,CAAC,CAAC;QACxD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KAC/D,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,2BAA2B,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,0BAA0B,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sCAAsC,EAAE,CAAC,EAAE,CAAC;IACvF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Gateway Route Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Gateway Routes (path → service mappings).
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export declare function registerGatewayRouteTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=gateway-route.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-route.tools.d.ts","sourceRoot":"","sources":["../../src/tools/gateway-route.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmFjE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Gateway Route Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Gateway Routes (path → service mappings).
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { sopoGet, sopoPost, sopoPatch, sopoDelete } from '../sopo-client.js';
|
|
8
|
+
export function registerGatewayRouteTools(server) {
|
|
9
|
+
// ── List Gateway Routes ───────────────────────────────────────
|
|
10
|
+
server.tool('list_gateway_routes', 'List all gateway routes. Returns path, target_path, method, gateway_id, service_id, timeout, retry settings, and aggregation config.', {}, async () => {
|
|
11
|
+
const result = await sopoGet('/api/v1/gateway-routes');
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
16
|
+
});
|
|
17
|
+
// ── Create Gateway Route ──────────────────────────────────────
|
|
18
|
+
server.tool('create_gateway_route', 'Create a new route that maps an incoming path to a downstream service. Requires path, gateway_id, and service_id. Both IDs MUST reference existing resources.', {
|
|
19
|
+
path: z.string().describe('Incoming request path (e.g. "/api/v1/users")'),
|
|
20
|
+
target_path: z.string().optional().describe('Downstream target path (defaults to same as path)'),
|
|
21
|
+
method: z.string().optional().describe('HTTP method (GET, POST, etc.) or empty for all'),
|
|
22
|
+
gateway_id: z.string().uuid().describe('UUID of the parent gateway (must exist)'),
|
|
23
|
+
service_id: z.string().uuid().describe('UUID of the target service (must exist)'),
|
|
24
|
+
timeout: z.string().optional().describe('Request timeout (e.g. "30s")'),
|
|
25
|
+
retry_max_attempts: z.number().optional().describe('Max retry attempts'),
|
|
26
|
+
collection_id: z.string().uuid().optional().describe('Optional collection ID (Pro mode)'),
|
|
27
|
+
aggregate_merge_strategy: z.string().optional().describe('Aggregation merge strategy'),
|
|
28
|
+
aggregate_timeout: z.string().optional().describe('Aggregation timeout'),
|
|
29
|
+
}, async (args) => {
|
|
30
|
+
const result = await sopoPost('/api/v1/gateway-routes', args);
|
|
31
|
+
if (!result.success) {
|
|
32
|
+
return { content: [{ type: 'text', text: `Error creating route: ${result.error}` }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
return { content: [{ type: 'text', text: `Gateway route created:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
35
|
+
});
|
|
36
|
+
// ── Update Gateway Route ──────────────────────────────────────
|
|
37
|
+
server.tool('update_gateway_route', 'Update an existing gateway route by its UUID.', {
|
|
38
|
+
id: z.string().uuid().describe('UUID of the route to update'),
|
|
39
|
+
path: z.string().optional().describe('New incoming path'),
|
|
40
|
+
target_path: z.string().optional().describe('New downstream path'),
|
|
41
|
+
method: z.string().optional().describe('HTTP method'),
|
|
42
|
+
gateway_id: z.string().uuid().optional().describe('New gateway ID'),
|
|
43
|
+
service_id: z.string().uuid().optional().describe('New service ID'),
|
|
44
|
+
timeout: z.string().optional().describe('New timeout'),
|
|
45
|
+
retry_max_attempts: z.number().optional().describe('New max retries'),
|
|
46
|
+
collection_id: z.string().uuid().optional().describe('Collection ID'),
|
|
47
|
+
aggregate_merge_strategy: z.string().optional().describe('Merge strategy'),
|
|
48
|
+
aggregate_timeout: z.string().optional().describe('Aggregate timeout'),
|
|
49
|
+
}, async (args) => {
|
|
50
|
+
const { id, ...body } = args;
|
|
51
|
+
const result = await sopoPatch(`/api/v1/gateway-routes/${id}`, body);
|
|
52
|
+
if (!result.success) {
|
|
53
|
+
return { content: [{ type: 'text', text: `Error updating route: ${result.error}` }], isError: true };
|
|
54
|
+
}
|
|
55
|
+
return { content: [{ type: 'text', text: `Gateway route updated:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
56
|
+
});
|
|
57
|
+
// ── Delete Gateway Route ──────────────────────────────────────
|
|
58
|
+
server.tool('delete_gateway_route', 'Delete a gateway route by its UUID.', {
|
|
59
|
+
id: z.string().uuid().describe('UUID of the route to delete'),
|
|
60
|
+
}, async (args) => {
|
|
61
|
+
const result = await sopoDelete(`/api/v1/gateway-routes/${args.id}`);
|
|
62
|
+
if (!result.success) {
|
|
63
|
+
return { content: [{ type: 'text', text: `Error deleting route: ${result.error}` }], isError: true };
|
|
64
|
+
}
|
|
65
|
+
return { content: [{ type: 'text', text: `Gateway route deleted successfully.` }] };
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=gateway-route.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-route.tools.js","sourceRoot":"","sources":["../../src/tools/gateway-route.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7E,MAAM,UAAU,yBAAyB,CAAC,MAAiB;IAEzD,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,qBAAqB,EACrB,sIAAsI,EACtI,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxF,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;IAEF,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,+JAA+J,EAC/J;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8CAA8C,CAAC;QACzE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mDAA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AE,MAAM,EAAE,IAAI,EAAE,qCAAqC,EAAE,CAAC,EAAE,CAAC;IACtF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Gateway Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing API Gateways in the Sopo platform.
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export declare function registerGatewayTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=gateway.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.tools.d.ts","sourceRoot":"","sources":["../../src/tools/gateway.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuE5D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Gateway Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing API Gateways in the Sopo platform.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { sopoGet, sopoPost, sopoPatch, sopoDelete } from '../sopo-client.js';
|
|
8
|
+
export function registerGatewayTools(server) {
|
|
9
|
+
// ── List Gateways ─────────────────────────────────────────────
|
|
10
|
+
server.tool('list_gateways', 'List all API gateways owned by the authenticated user. Returns id, name, description, is_active, and mode for each gateway.', {}, async () => {
|
|
11
|
+
const result = await sopoGet('/api/v1/gateways');
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
16
|
+
});
|
|
17
|
+
// ── Create Gateway ────────────────────────────────────────────
|
|
18
|
+
server.tool('create_gateway', 'Create a new API gateway. Requires a name. Optionally provide description, is_active (default true), and mode ("single" or "pro").', {
|
|
19
|
+
name: z.string().describe('Name of the gateway'),
|
|
20
|
+
description: z.string().optional().describe('Description of the gateway'),
|
|
21
|
+
is_active: z.boolean().optional().default(true).describe('Whether the gateway is active'),
|
|
22
|
+
mode: z.string().optional().describe('Gateway mode: "single" or "pro"'),
|
|
23
|
+
}, async (args) => {
|
|
24
|
+
const result = await sopoPost('/api/v1/gateways', args);
|
|
25
|
+
if (!result.success) {
|
|
26
|
+
return { content: [{ type: 'text', text: `Error creating gateway: ${result.error}` }], isError: true };
|
|
27
|
+
}
|
|
28
|
+
return { content: [{ type: 'text', text: `Gateway created successfully:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
29
|
+
});
|
|
30
|
+
// ── Update Gateway ────────────────────────────────────────────
|
|
31
|
+
server.tool('update_gateway', 'Update an existing gateway by its UUID. You can change name, description, is_active, or mode.', {
|
|
32
|
+
id: z.string().uuid().describe('UUID of the gateway to update'),
|
|
33
|
+
name: z.string().optional().describe('New name'),
|
|
34
|
+
description: z.string().optional().describe('New description'),
|
|
35
|
+
is_active: z.boolean().optional().describe('Set active/inactive'),
|
|
36
|
+
mode: z.string().optional().describe('Gateway mode: "single" or "pro"'),
|
|
37
|
+
}, async (args) => {
|
|
38
|
+
const { id, ...body } = args;
|
|
39
|
+
const result = await sopoPatch(`/api/v1/gateways/${id}`, body);
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
return { content: [{ type: 'text', text: `Error updating gateway: ${result.error}` }], isError: true };
|
|
42
|
+
}
|
|
43
|
+
return { content: [{ type: 'text', text: `Gateway updated successfully:\n${JSON.stringify(result.data, null, 2)}` }] };
|
|
44
|
+
});
|
|
45
|
+
// ── Delete Gateway ────────────────────────────────────────────
|
|
46
|
+
server.tool('delete_gateway', 'Delete a gateway by its UUID. This will also cascade-delete related services, routes, and plugins.', {
|
|
47
|
+
id: z.string().uuid().describe('UUID of the gateway to delete'),
|
|
48
|
+
}, async (args) => {
|
|
49
|
+
const result = await sopoDelete(`/api/v1/gateways/${args.id}`);
|
|
50
|
+
if (!result.success) {
|
|
51
|
+
return { content: [{ type: 'text', text: `Error deleting gateway: ${result.error}` }], isError: true };
|
|
52
|
+
}
|
|
53
|
+
return { content: [{ type: 'text', text: `Gateway deleted successfully.` }] };
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=gateway.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.tools.js","sourceRoot":"","sources":["../../src/tools/gateway.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG7E,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IAEpD,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,eAAe,EACf,6HAA6H,EAC7H,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxF,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;IAEF,iEAAiE;IACjE,MAAM,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AM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,+BAA+B,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Observability Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for reading logs, metrics, and resource statistics from the Sopo platform.
|
|
5
|
+
* These are read-only tools that provide the AI with visibility into the system state.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
export declare function registerObservabilityTools(server: McpServer): void;
|
|
9
|
+
//# sourceMappingURL=observability.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.tools.d.ts","sourceRoot":"","sources":["../../src/tools/observability.tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2ElE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Observability Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for reading logs, metrics, and resource statistics from the Sopo platform.
|
|
5
|
+
* These are read-only tools that provide the AI with visibility into the system state.
|
|
6
|
+
*/
|
|
7
|
+
import { sopoGet } from '../sopo-client.js';
|
|
8
|
+
export function registerObservabilityTools(server) {
|
|
9
|
+
// ── Health Check ──────────────────────────────────────────────
|
|
10
|
+
server.tool('check_health', 'Check the health status of the Sopo Backend. Returns "ok" if the backend is running and responsive.', {}, async () => {
|
|
11
|
+
const result = await sopoGet('/health');
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
return { content: [{ type: 'text', text: `Backend is unreachable: ${result.error}` }], isError: true };
|
|
14
|
+
}
|
|
15
|
+
return { content: [{ type: 'text', text: `Backend status: ${JSON.stringify(result.data, null, 2)}` }] };
|
|
16
|
+
});
|
|
17
|
+
// ── Resource Stats ────────────────────────────────────────────
|
|
18
|
+
server.tool('get_resource_stats', 'Get resource counts (gateways, services, routes, plugins) for the authenticated user, including per-gateway breakdown. Great for getting an overview of the platform usage.', {}, async () => {
|
|
19
|
+
const result = await sopoGet('/api/v1/stats/resources');
|
|
20
|
+
if (!result.success) {
|
|
21
|
+
return { content: [{ type: 'text', text: `Error: ${result.error}` }], isError: true };
|
|
22
|
+
}
|
|
23
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
24
|
+
});
|
|
25
|
+
// ── Request Logs ──────────────────────────────────────────────
|
|
26
|
+
server.tool('get_request_logs', 'Fetch recent gateway request logs from ClickHouse. Returns timestamp, method, path, status_code, latency_ms, client_ip, and more for each request.', {}, async () => {
|
|
27
|
+
const result = await sopoGet('/api/v1/logs/requests');
|
|
28
|
+
if (!result.success) {
|
|
29
|
+
return { content: [{ type: 'text', text: `Error fetching logs: ${result.error}` }], isError: true };
|
|
30
|
+
}
|
|
31
|
+
const data = result.data;
|
|
32
|
+
if (Array.isArray(data) && data.length > 50) {
|
|
33
|
+
return { content: [{ type: 'text', text: `Showing last 50 of ${data.length} logs:\n${JSON.stringify(data.slice(0, 50), null, 2)}` }] };
|
|
34
|
+
}
|
|
35
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
36
|
+
});
|
|
37
|
+
// ── Hourly Metrics ────────────────────────────────────────────
|
|
38
|
+
server.tool('get_hourly_metrics', 'Fetch aggregated hourly gateway metrics (last 24 hours). Returns total_requests, total_errors, avg/min/max latency per hour per gateway.', {}, async () => {
|
|
39
|
+
const result = await sopoGet('/api/v1/logs/hourly-metrics');
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
return { content: [{ type: 'text', text: `Error fetching metrics: ${result.error}` }], isError: true };
|
|
42
|
+
}
|
|
43
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
44
|
+
});
|
|
45
|
+
// ── Hourly Metrics (Materialized View) ────────────────────────
|
|
46
|
+
server.tool('get_hourly_metrics_mv', 'Fetch aggregated hourly gateway metrics from a ClickHouse materialized view. Faster than regular hourly metrics.', {}, async () => {
|
|
47
|
+
const result = await sopoGet('/api/v1/logs/hourly-metrics-mv');
|
|
48
|
+
if (!result.success) {
|
|
49
|
+
return { content: [{ type: 'text', text: `Error fetching metrics: ${result.error}` }], isError: true };
|
|
50
|
+
}
|
|
51
|
+
return { content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }] };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=observability.tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.tools.js","sourceRoot":"","sources":["../../src/tools/observability.tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,MAAM,UAAU,0BAA0B,CAAC,MAAiB;IAE1D,iEAAiE;IACjE,MAAM,CAAC,IAAI,CACT,cAAc,EACd,qGAAqG,EACrG,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO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ACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,gCAAgC,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzG,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrF,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sopo MCP Server — Service Target Tools
|
|
3
|
+
*
|
|
4
|
+
* CRUD tools for managing Service Targets (upstream URLs / load balancing endpoints).
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
export declare function registerServiceTargetTools(server: McpServer): void;
|
|
8
|
+
//# sourceMappingURL=service-target.tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-target.tools.d.ts","sourceRoot":"","sources":["../../src/tools/service-target.tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAmElE"}
|