@ratio-mcp-qa/docs-server 1.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.
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/oauth.json +71 -0
- package/dist/schemas/orders.json +167 -0
- package/dist/schemas/products.json +167 -0
- package/dist/schemas/schemas/oauth.json +71 -0
- package/dist/schemas/schemas/orders.json +167 -0
- package/dist/schemas/schemas/products.json +167 -0
- package/dist/schemas/schemas/scopes.json +52 -0
- package/dist/schemas/schemas/webhooks.json +69 -0
- package/dist/schemas/scopes.json +52 -0
- package/dist/schemas/webhooks.json +69 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +53 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/get-api-reference.d.ts +60 -0
- package/dist/tools/get-api-reference.d.ts.map +1 -0
- package/dist/tools/get-api-reference.js +53 -0
- package/dist/tools/get-api-reference.js.map +1 -0
- package/dist/tools/get-scope-map.d.ts +17 -0
- package/dist/tools/get-scope-map.d.ts.map +1 -0
- package/dist/tools/get-scope-map.js +102 -0
- package/dist/tools/get-scope-map.js.map +1 -0
- package/dist/tools/get-scopes.d.ts +63 -0
- package/dist/tools/get-scopes.d.ts.map +1 -0
- package/dist/tools/get-scopes.js +72 -0
- package/dist/tools/get-scopes.js.map +1 -0
- package/dist/tools/get-webhooks.d.ts +30 -0
- package/dist/tools/get-webhooks.d.ts.map +1 -0
- package/dist/tools/get-webhooks.js +32 -0
- package/dist/tools/get-webhooks.js.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +110 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/lookup-docs.d.ts +58 -0
- package/dist/tools/lookup-docs.d.ts.map +1 -0
- package/dist/tools/lookup-docs.js +181 -0
- package/dist/tools/lookup-docs.js.map +1 -0
- package/dist/tools/validate-code.d.ts +12 -0
- package/dist/tools/validate-code.d.ts.map +1 -0
- package/dist/tools/validate-code.js +185 -0
- package/dist/tools/validate-code.js.map +1 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +85 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/schema-loader.d.ts +13 -0
- package/dist/utils/schema-loader.d.ts.map +1 -0
- package/dist/utils/schema-loader.js +61 -0
- package/dist/utils/schema-loader.js.map +1 -0
- package/dist/utils/zod-to-json.d.ts +7 -0
- package/dist/utils/zod-to-json.d.ts.map +1 -0
- package/dist/utils/zod-to-json.js +63 -0
- package/dist/utils/zod-to-json.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;IAEH,qBAAqB;IACrB,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,8EAA8E;QAC9E,MAAM,KAAK,GAAI,IAAI,CAAC,WAA0C,CAAC,KAAK,CAAC;QAErE,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,KAAK,EACL,KAAK,EAAE,IAA6B,EAAE,EAAE;YACtC,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AG,gBAAgB,qBAAqB,SAAS,CAAC,MAAM,QAAQ,CAAC,CAAC;IAC9E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_api_reference — Returns complete API reference for a resource.
|
|
3
|
+
* Optionally filters by scope to show only endpoints accessible with that scope.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getApiReference(input: {
|
|
6
|
+
resource: string;
|
|
7
|
+
scope_filter?: string;
|
|
8
|
+
}): {
|
|
9
|
+
error: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
available_resources: string[];
|
|
12
|
+
available_scopes?: undefined;
|
|
13
|
+
resource?: undefined;
|
|
14
|
+
base_url?: undefined;
|
|
15
|
+
auth?: undefined;
|
|
16
|
+
endpoint_count?: undefined;
|
|
17
|
+
endpoints?: undefined;
|
|
18
|
+
schemas?: undefined;
|
|
19
|
+
statuses?: undefined;
|
|
20
|
+
scope_filter_applied?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
error: boolean;
|
|
23
|
+
message: string;
|
|
24
|
+
available_scopes: string[];
|
|
25
|
+
available_resources?: undefined;
|
|
26
|
+
resource?: undefined;
|
|
27
|
+
base_url?: undefined;
|
|
28
|
+
auth?: undefined;
|
|
29
|
+
endpoint_count?: undefined;
|
|
30
|
+
endpoints?: undefined;
|
|
31
|
+
schemas?: undefined;
|
|
32
|
+
statuses?: undefined;
|
|
33
|
+
scope_filter_applied?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
resource: string;
|
|
36
|
+
base_url: string;
|
|
37
|
+
auth: Record<string, string> | undefined;
|
|
38
|
+
endpoint_count: number;
|
|
39
|
+
endpoints: {
|
|
40
|
+
method: string;
|
|
41
|
+
path: string;
|
|
42
|
+
controller_order: number;
|
|
43
|
+
handler_name: string;
|
|
44
|
+
required_scope: string;
|
|
45
|
+
summary: string;
|
|
46
|
+
description: string | undefined;
|
|
47
|
+
query_params: import("@ratio-mcp-qa/shared").EndpointParam[];
|
|
48
|
+
path_params: import("@ratio-mcp-qa/shared").EndpointParam[];
|
|
49
|
+
request_body: Record<string, unknown> | null;
|
|
50
|
+
response_schema: string | null;
|
|
51
|
+
}[];
|
|
52
|
+
schemas: Record<string, unknown>;
|
|
53
|
+
statuses: string[];
|
|
54
|
+
scope_filter_applied: string | null;
|
|
55
|
+
error?: undefined;
|
|
56
|
+
message?: undefined;
|
|
57
|
+
available_resources?: undefined;
|
|
58
|
+
available_scopes?: undefined;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=get-api-reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-api-reference.d.ts","sourceRoot":"","sources":["../../src/tools/get-api-reference.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDjF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { loadResourceSchema, getAvailableResourceFiles } from '../utils/schema-loader.js';
|
|
2
|
+
/**
|
|
3
|
+
* get_api_reference — Returns complete API reference for a resource.
|
|
4
|
+
* Optionally filters by scope to show only endpoints accessible with that scope.
|
|
5
|
+
*/
|
|
6
|
+
export function getApiReference(input) {
|
|
7
|
+
const availableResources = getAvailableResourceFiles();
|
|
8
|
+
if (!availableResources.includes(input.resource)) {
|
|
9
|
+
return {
|
|
10
|
+
error: true,
|
|
11
|
+
message: `Unknown resource: "${input.resource}"`,
|
|
12
|
+
available_resources: availableResources,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const schema = loadResourceSchema(input.resource);
|
|
16
|
+
let endpoints = schema.endpoints;
|
|
17
|
+
// Filter by scope if provided
|
|
18
|
+
if (input.scope_filter) {
|
|
19
|
+
endpoints = endpoints.filter((ep) => ep.required_scope === input.scope_filter);
|
|
20
|
+
if (endpoints.length === 0) {
|
|
21
|
+
return {
|
|
22
|
+
error: true,
|
|
23
|
+
message: `No endpoints found for scope "${input.scope_filter}" in resource "${input.resource}"`,
|
|
24
|
+
available_scopes: [...new Set(schema.endpoints.map((ep) => ep.required_scope))],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// Sort by controller_order
|
|
29
|
+
endpoints = [...endpoints].sort((a, b) => a.controller_order - b.controller_order);
|
|
30
|
+
return {
|
|
31
|
+
resource: schema.resource,
|
|
32
|
+
base_url: schema.base_url,
|
|
33
|
+
auth: schema.auth,
|
|
34
|
+
endpoint_count: endpoints.length,
|
|
35
|
+
endpoints: endpoints.map((ep) => ({
|
|
36
|
+
method: ep.method,
|
|
37
|
+
path: ep.path,
|
|
38
|
+
controller_order: ep.controller_order,
|
|
39
|
+
handler_name: ep.handler_name,
|
|
40
|
+
required_scope: ep.required_scope,
|
|
41
|
+
summary: ep.summary,
|
|
42
|
+
description: ep.description,
|
|
43
|
+
query_params: ep.query_params || [],
|
|
44
|
+
path_params: ep.path_params || [],
|
|
45
|
+
request_body: ep.request_body || null,
|
|
46
|
+
response_schema: ep.response_schema || null,
|
|
47
|
+
})),
|
|
48
|
+
schemas: schema.schemas,
|
|
49
|
+
statuses: schema.statuses || [],
|
|
50
|
+
scope_filter_applied: input.scope_filter || null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=get-api-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-api-reference.js","sourceRoot":"","sources":["../../src/tools/get-api-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAE1F;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAkD;IAChF,MAAM,kBAAkB,GAAG,yBAAyB,EAAE,CAAC;IAEvD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E,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAChC,MAAM,EAAE,EAAE,CAAC,MAAM;YACjB,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,gBAAgB,EAAE,EAAE,CAAC,gBAAgB;YACrC,YAAY,EAAE,EAAE,CAAC,YAAY;YAC7B,cAAc,EAAE,EAAE,CAAC,cAAc;YACjC,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,WAAW,EAAE,EAAE,CAAC,WAAW;YAC3B,YAAY,EAAE,EAAE,CAAC,YAAY,IAAI,EAAE;YACnC,WAAW,EAAE,EAAE,CAAC,WAAW,IAAI,EAAE;YACjC,YAAY,EAAE,EAAE,CAAC,YAAY,IAAI,IAAI;YACrC,eAAe,EAAE,EAAE,CAAC,eAAe,IAAI,IAAI;SAC5C,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,EAAE;QAC/B,oBAAoB,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;KACjD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ScopeEndpointMapping } from '@ratio-mcp-qa/shared';
|
|
2
|
+
/**
|
|
3
|
+
* get_scope_endpoint_map — Given a list of scopes, returns exactly which endpoints
|
|
4
|
+
* are unlocked, in controller_order. This is what the codegen reads before generating routes.
|
|
5
|
+
*
|
|
6
|
+
* Works by scanning resource schema files and matching endpoints by required_scope.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getScopeEndpointMap(input: {
|
|
9
|
+
scopes: string[];
|
|
10
|
+
}): {
|
|
11
|
+
requested_scopes: string[];
|
|
12
|
+
resolved_scopes: string[];
|
|
13
|
+
total_endpoints: number;
|
|
14
|
+
mappings: ScopeEndpointMapping[];
|
|
15
|
+
_instruction: string;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=get-scope-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-scope-map.d.ts","sourceRoot":"","sources":["../../src/tools/get-scope-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AA6BjE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;;EAgF9D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { loadResourceSchema } from '../utils/schema-loader.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve scope inheritance:
|
|
4
|
+
* - write_X includes read_X
|
|
5
|
+
* - delete_X includes write_X and read_X
|
|
6
|
+
* - order-create / order-update / order-cancel include read_orders
|
|
7
|
+
* (these are custom scopes that don't follow the write_X pattern)
|
|
8
|
+
*/
|
|
9
|
+
function resolveInheritedScopes(scopes) {
|
|
10
|
+
const resolved = new Set(scopes);
|
|
11
|
+
for (const scope of scopes) {
|
|
12
|
+
if (scope.startsWith('write_')) {
|
|
13
|
+
const resource = scope.replace('write_', '');
|
|
14
|
+
resolved.add(`read_${resource}`);
|
|
15
|
+
}
|
|
16
|
+
else if (scope.startsWith('delete_')) {
|
|
17
|
+
const resource = scope.replace('delete_', '');
|
|
18
|
+
resolved.add(`write_${resource}`);
|
|
19
|
+
resolved.add(`read_${resource}`);
|
|
20
|
+
}
|
|
21
|
+
else if (['order-create', 'order-update', 'order-cancel'].includes(scope)) {
|
|
22
|
+
// Custom order scopes inherit read_orders
|
|
23
|
+
resolved.add('read_orders');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return resolved;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* get_scope_endpoint_map — Given a list of scopes, returns exactly which endpoints
|
|
30
|
+
* are unlocked, in controller_order. This is what the codegen reads before generating routes.
|
|
31
|
+
*
|
|
32
|
+
* Works by scanning resource schema files and matching endpoints by required_scope.
|
|
33
|
+
*/
|
|
34
|
+
export function getScopeEndpointMap(input) {
|
|
35
|
+
const result = [];
|
|
36
|
+
// Resolve scope inheritance
|
|
37
|
+
const resolvedScopes = resolveInheritedScopes(input.scopes);
|
|
38
|
+
// Determine which resources to scan based on scope names
|
|
39
|
+
// Scope format: read_orders → resource "orders", write_products → resource "products"
|
|
40
|
+
const resourceNames = new Set();
|
|
41
|
+
for (const scope of resolvedScopes) {
|
|
42
|
+
// Extract resource name by removing the prefix (read_, write_, delete_, or custom like order-create)
|
|
43
|
+
const match = scope.match(/^(?:read_|write_|delete_)(.+)$/);
|
|
44
|
+
if (match) {
|
|
45
|
+
resourceNames.add(match[1]);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// For custom scopes like "order-create", try to extract resource from the scope code
|
|
49
|
+
const parts = scope.split(/[-_]/);
|
|
50
|
+
if (parts.length > 0) {
|
|
51
|
+
resourceNames.add(parts[0]);
|
|
52
|
+
// Also try plural form
|
|
53
|
+
resourceNames.add(parts[0] + 's');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Group endpoints by resource
|
|
58
|
+
const endpointsByResource = new Map();
|
|
59
|
+
for (const resourceName of resourceNames) {
|
|
60
|
+
try {
|
|
61
|
+
const resourceSchema = loadResourceSchema(resourceName);
|
|
62
|
+
const matchingEndpoints = resourceSchema.endpoints
|
|
63
|
+
.filter((ep) => resolvedScopes.has(ep.required_scope))
|
|
64
|
+
.map((ep) => ({
|
|
65
|
+
method: ep.method,
|
|
66
|
+
path: ep.path,
|
|
67
|
+
controller_order: ep.controller_order,
|
|
68
|
+
handler_name: ep.handler_name,
|
|
69
|
+
summary: ep.summary,
|
|
70
|
+
required_scope: ep.required_scope,
|
|
71
|
+
}));
|
|
72
|
+
if (matchingEndpoints.length > 0) {
|
|
73
|
+
const existing = endpointsByResource.get(resourceName) || [];
|
|
74
|
+
existing.push(...matchingEndpoints);
|
|
75
|
+
endpointsByResource.set(resourceName, existing);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Resource schema file not found — skip
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Build result sorted by controller_order within each resource
|
|
83
|
+
for (const [resourceName, endpoints] of endpointsByResource) {
|
|
84
|
+
const sorted = endpoints.sort((a, b) => a.controller_order - b.controller_order);
|
|
85
|
+
result.push({
|
|
86
|
+
scope: input.scopes.filter((s) => {
|
|
87
|
+
const match = s.match(/^(?:read_|write_|delete_)(.+)$/);
|
|
88
|
+
return match && match[1] === resourceName;
|
|
89
|
+
}).join(', '),
|
|
90
|
+
resource: resourceName,
|
|
91
|
+
endpoints: sorted,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
requested_scopes: input.scopes,
|
|
96
|
+
resolved_scopes: [...resolvedScopes],
|
|
97
|
+
total_endpoints: result.reduce((sum, r) => sum + r.endpoints.length, 0),
|
|
98
|
+
mappings: result,
|
|
99
|
+
_instruction: 'Use these endpoints in controller_order for deterministic code generation.',
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=get-scope-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-scope-map.js","sourceRoot":"","sources":["../../src/tools/get-scope-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA6B,MAAM,2BAA2B,CAAC;AAG1F;;;;;;GAMG;AACH,SAAS,sBAAsB,CAAC,MAAgB;IAC9C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,CAAC;IAEzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC7C,QAAQ,CAAC,GAAG,CAAC,QAA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5D,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;QACjF,MAAM,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC/B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;gBACxD,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC;YAC5C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACb,QAAQ,EAAE,YAAY;YACtB,SAAS,EAAE,MAAM;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,gBAAgB,EAAE,KAAK,CAAC,MAAM;QAC9B,eAAe,EAAE,CAAC,GAAG,cAAc,CAAC;QACpC,eAAe,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QACvE,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,4EAA4E;KAC3F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_available_scopes — Returns all available scopes grouped by primary resource.
|
|
3
|
+
* Returns all scopes from the platform grouped by resource.
|
|
4
|
+
* Data sourced from GET /api/v1/scopes — all 147 scopes across 78 resources.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getAvailableScopes(input: {
|
|
7
|
+
resource?: string;
|
|
8
|
+
}): {
|
|
9
|
+
error: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
available_resources: string[];
|
|
12
|
+
resource?: undefined;
|
|
13
|
+
resource_info?: undefined;
|
|
14
|
+
scopes?: undefined;
|
|
15
|
+
total?: undefined;
|
|
16
|
+
total_resources?: undefined;
|
|
17
|
+
total_scopes?: undefined;
|
|
18
|
+
resources?: undefined;
|
|
19
|
+
_instruction?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
resource: string;
|
|
22
|
+
resource_info: {
|
|
23
|
+
description: string;
|
|
24
|
+
codegen_ready: boolean;
|
|
25
|
+
commonly_needed_with: string[] | undefined;
|
|
26
|
+
example_app_types: string[] | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
scopes: {
|
|
29
|
+
code: string;
|
|
30
|
+
label: string;
|
|
31
|
+
}[];
|
|
32
|
+
total: number;
|
|
33
|
+
error?: undefined;
|
|
34
|
+
message?: undefined;
|
|
35
|
+
available_resources?: undefined;
|
|
36
|
+
total_resources?: undefined;
|
|
37
|
+
total_scopes?: undefined;
|
|
38
|
+
resources?: undefined;
|
|
39
|
+
_instruction?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
total_resources: number;
|
|
42
|
+
total_scopes: number;
|
|
43
|
+
resources: {
|
|
44
|
+
resource: string;
|
|
45
|
+
description: string;
|
|
46
|
+
codegen_ready: boolean;
|
|
47
|
+
is_primary: boolean;
|
|
48
|
+
scopes: {
|
|
49
|
+
code: string;
|
|
50
|
+
label: string;
|
|
51
|
+
}[];
|
|
52
|
+
count: number;
|
|
53
|
+
}[];
|
|
54
|
+
_instruction: string;
|
|
55
|
+
error?: undefined;
|
|
56
|
+
message?: undefined;
|
|
57
|
+
available_resources?: undefined;
|
|
58
|
+
resource?: undefined;
|
|
59
|
+
resource_info?: undefined;
|
|
60
|
+
scopes?: undefined;
|
|
61
|
+
total?: undefined;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=get-scopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-scopes.d.ts","sourceRoot":"","sources":["../../src/tools/get-scopes.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqE9D"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SCOPES_BY_RESOURCE, PRIMARY_RESOURCES, RESOURCE_METADATA, getAllResources } from '@ratio-mcp-qa/shared';
|
|
2
|
+
/**
|
|
3
|
+
* get_available_scopes — Returns all available scopes grouped by primary resource.
|
|
4
|
+
* Returns all scopes from the platform grouped by resource.
|
|
5
|
+
* Data sourced from GET /api/v1/scopes — all 147 scopes across 78 resources.
|
|
6
|
+
*/
|
|
7
|
+
export function getAvailableScopes(input) {
|
|
8
|
+
if (input.resource) {
|
|
9
|
+
const resourceScopes = SCOPES_BY_RESOURCE[input.resource];
|
|
10
|
+
const resourceMeta = RESOURCE_METADATA[input.resource];
|
|
11
|
+
if (!resourceScopes) {
|
|
12
|
+
return {
|
|
13
|
+
error: true,
|
|
14
|
+
message: `Unknown resource: "${input.resource}"`,
|
|
15
|
+
available_resources: getAllResources(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
resource: input.resource,
|
|
20
|
+
resource_info: resourceMeta
|
|
21
|
+
? {
|
|
22
|
+
description: resourceMeta.description,
|
|
23
|
+
codegen_ready: resourceMeta.codegen_ready,
|
|
24
|
+
commonly_needed_with: resourceMeta.commonly_needed_with,
|
|
25
|
+
example_app_types: resourceMeta.example_app_types,
|
|
26
|
+
}
|
|
27
|
+
: undefined,
|
|
28
|
+
scopes: resourceScopes.map((s) => ({
|
|
29
|
+
code: s.code,
|
|
30
|
+
label: s.label,
|
|
31
|
+
})),
|
|
32
|
+
total: resourceScopes.length,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Return ALL resources with their scopes — primary resources first with metadata, then the rest
|
|
36
|
+
const allResourceNames = getAllResources();
|
|
37
|
+
const primarySet = new Set(PRIMARY_RESOURCES);
|
|
38
|
+
const resources = allResourceNames.map((resourceName) => {
|
|
39
|
+
const scopes = SCOPES_BY_RESOURCE[resourceName] || [];
|
|
40
|
+
const meta = RESOURCE_METADATA[resourceName];
|
|
41
|
+
return {
|
|
42
|
+
resource: resourceName,
|
|
43
|
+
description: meta?.description || '',
|
|
44
|
+
codegen_ready: meta?.codegen_ready || false,
|
|
45
|
+
is_primary: primarySet.has(resourceName),
|
|
46
|
+
scopes: scopes.map((s) => ({
|
|
47
|
+
code: s.code,
|
|
48
|
+
label: s.label,
|
|
49
|
+
})),
|
|
50
|
+
count: scopes.length,
|
|
51
|
+
};
|
|
52
|
+
})
|
|
53
|
+
// Sort: primary resources first, then alphabetical
|
|
54
|
+
.sort((a, b) => {
|
|
55
|
+
if (a.is_primary && !b.is_primary)
|
|
56
|
+
return -1;
|
|
57
|
+
if (!a.is_primary && b.is_primary)
|
|
58
|
+
return 1;
|
|
59
|
+
return a.resource.localeCompare(b.resource);
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
total_resources: resources.length,
|
|
63
|
+
total_scopes: resources.reduce((sum, r) => sum + r.count, 0),
|
|
64
|
+
resources,
|
|
65
|
+
_instruction: 'These are ALL scopes available on the platform (sourced from the real API). ' +
|
|
66
|
+
'Primary resources are listed first — these are the most commonly needed. ' +
|
|
67
|
+
'codegen_ready=true means generate_api_routes can auto-generate backend code for that resource. ' +
|
|
68
|
+
'Present the scopes to the developer grouped by resource. Let them pick what they need. ' +
|
|
69
|
+
'After selecting scopes, call define_app_requirements with confirmed=false for preview, then confirmed=true.',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=get-scopes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-scopes.js","sourceRoot":"","sources":["../../src/tools/get-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAs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BAAiB,CAAC,YAAY,CAAC,CAAC;QAE7C,OAAO;YACL,QAAQ,EAAE,YAAY;YACtB,WAAW,EAAE,IAAI,EAAE,WAAW,IAAI,EAAE;YACpC,aAAa,EAAE,IAAI,EAAE,aAAa,IAAI,KAAK;YAC3C,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC;YACxC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,CAAC,CAAC,KAAK;aACf,CAAC,CAAC;YACH,KAAK,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC;IACJ,CAAC,CAAC;QACF,mDAAmD;SAClD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,UAAU;YAAE,OAAO,CAAC,CAAC,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,UAAU;YAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,eAAe,EAAE,SAAS,CAAC,MAAM;QACjC,YAAY,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5D,SAAS;QACT,YAAY,EACV,8EAA8E;YAC9E,2EAA2E;YAC3E,iGAAiG;YACjG,yFAAyF;YACzF,6GAA6G;KAChH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_webhook_events — Returns available webhook events, optionally filtered by resource.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getWebhookEvents(input: {
|
|
5
|
+
resource?: string;
|
|
6
|
+
}): {
|
|
7
|
+
error: boolean;
|
|
8
|
+
message: string;
|
|
9
|
+
available_resources: string[];
|
|
10
|
+
total_events?: undefined;
|
|
11
|
+
verification?: undefined;
|
|
12
|
+
retry_policy?: undefined;
|
|
13
|
+
events?: undefined;
|
|
14
|
+
resource_filter?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
total_events: number;
|
|
17
|
+
verification: Record<string, string> | undefined;
|
|
18
|
+
retry_policy: Record<string, unknown> | undefined;
|
|
19
|
+
events: {
|
|
20
|
+
topic: string;
|
|
21
|
+
description: string;
|
|
22
|
+
resource: string;
|
|
23
|
+
required_scope: string | null | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
resource_filter: string | null;
|
|
26
|
+
error?: undefined;
|
|
27
|
+
message?: undefined;
|
|
28
|
+
available_resources?: undefined;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=get-webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-webhooks.d.ts","sourceRoot":"","sources":["../../src/tools/get-webhooks.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;EA6B5D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { loadWebhooks } from '../utils/schema-loader.js';
|
|
2
|
+
/**
|
|
3
|
+
* get_webhook_events — Returns available webhook events, optionally filtered by resource.
|
|
4
|
+
*/
|
|
5
|
+
export function getWebhookEvents(input) {
|
|
6
|
+
const webhooks = loadWebhooks();
|
|
7
|
+
let events = webhooks.events;
|
|
8
|
+
if (input.resource) {
|
|
9
|
+
events = events.filter((e) => e.resource === input.resource);
|
|
10
|
+
if (events.length === 0) {
|
|
11
|
+
const availableResources = [...new Set(webhooks.events.map((e) => e.resource))];
|
|
12
|
+
return {
|
|
13
|
+
error: true,
|
|
14
|
+
message: `No webhook events found for resource: "${input.resource}"`,
|
|
15
|
+
available_resources: availableResources,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
total_events: events.length,
|
|
21
|
+
verification: webhooks.verification,
|
|
22
|
+
retry_policy: webhooks.retry_policy,
|
|
23
|
+
events: events.map((e) => ({
|
|
24
|
+
topic: e.topic,
|
|
25
|
+
description: e.description,
|
|
26
|
+
resource: e.resource,
|
|
27
|
+
required_scope: e.required_scope,
|
|
28
|
+
})),
|
|
29
|
+
resource_filter: input.resource || null,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=get-webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-webhooks.js","sourceRoot":"","sources":["../../src/tools/get-webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAEhC,IAAI,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAE7B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAChF,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,0CAA0C,KAAK,CAAC,QAAQ,GAAG;gBACpE,mBAAmB,EAAE,kBAAkB;aACxC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,MAAM;QAC3B,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,WAAW,EAAE,CAAC,CAAC,WAAW;YAC1B,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,cAAc,EAAE,CAAC,CAAC,cAAc;SACjC,CAAC,CAAC;QACH,eAAe,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Tool definition for MCP registration
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolDefinition {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: z.ZodType;
|
|
9
|
+
handler: (input: Record<string, unknown>) => unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* All docs-server tools (6 tools)
|
|
13
|
+
*/
|
|
14
|
+
export declare const docsTools: ToolDefinition[];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC;IACvB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,cAAc,EAyGrC,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getAvailableScopes } from './get-scopes.js';
|
|
3
|
+
import { getApiReference } from './get-api-reference.js';
|
|
4
|
+
import { getScopeEndpointMap } from './get-scope-map.js';
|
|
5
|
+
import { validateApiCode } from './validate-code.js';
|
|
6
|
+
import { getWebhookEvents } from './get-webhooks.js';
|
|
7
|
+
import { lookupDocs } from './lookup-docs.js';
|
|
8
|
+
/**
|
|
9
|
+
* All docs-server tools (6 tools)
|
|
10
|
+
*/
|
|
11
|
+
export const docsTools = [
|
|
12
|
+
{
|
|
13
|
+
name: 'lookup_docs',
|
|
14
|
+
description: 'MANDATORY FALLBACK: When you are unsure about ANY platform detail (API endpoints, scopes, webhooks, OAuth flow, ' +
|
|
15
|
+
'request/response formats, error codes), call this tool BEFORE answering. ' +
|
|
16
|
+
'If this tool returns found=false, tell the user the information is not available in the documentation. ' +
|
|
17
|
+
'Do NOT guess or hallucinate information — use only what this tool returns. ' +
|
|
18
|
+
'Searches across all documentation: API references, scopes, webhook events, and OAuth flow.',
|
|
19
|
+
inputSchema: z.object({
|
|
20
|
+
query: z.string().min(1).describe('Natural language search query (e.g., "how to cancel an order", "webhook verification")'),
|
|
21
|
+
category: z
|
|
22
|
+
.enum(['api', 'scopes', 'webhooks', 'oauth'])
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Optional category to narrow the search'),
|
|
25
|
+
}),
|
|
26
|
+
handler: (input) => lookupDocs(input),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'get_available_scopes',
|
|
30
|
+
description: 'MANDATORY: Call this tool before answering ANY question about what OAuth scopes exist, what they grant access to, ' +
|
|
31
|
+
'or what resources are available on the platform. Do NOT rely on your training data for scope specifics. ' +
|
|
32
|
+
'If a scope is not returned by this tool, it does not exist — tell the user. ' +
|
|
33
|
+
'Returns all available OAuth scopes grouped by resource. ' +
|
|
34
|
+
'Optionally filter by resource name (e.g. "orders", "products", "customers"). ' +
|
|
35
|
+
'Returns all 78 resources with their scopes (147 total), sourced from the real platform API. ' +
|
|
36
|
+
'Primary resources are listed first. Each resource shows codegen_ready status. ' +
|
|
37
|
+
'Use this to show developers what scopes are available on the platform.',
|
|
38
|
+
inputSchema: z.object({
|
|
39
|
+
resource: z
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Optional resource name to filter scopes (e.g. "orders", "customers", "discounts")'),
|
|
43
|
+
}),
|
|
44
|
+
handler: (input) => getAvailableScopes(input),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'get_api_reference',
|
|
48
|
+
description: 'MANDATORY: Call this tool before answering ANY question about API endpoints, request/response formats, ' +
|
|
49
|
+
'HTTP methods, query parameters, or request bodies. Do NOT guess endpoint details from your training data. ' +
|
|
50
|
+
'Returns complete API reference for a resource including all endpoints, parameters, request/response schemas. ' +
|
|
51
|
+
'Endpoints are returned in controller_order for deterministic code generation. ' +
|
|
52
|
+
'Optionally filter by scope to show only endpoints accessible with that scope.',
|
|
53
|
+
inputSchema: z.object({
|
|
54
|
+
resource: z.string().describe('Resource name (e.g. "orders", "products")'),
|
|
55
|
+
scope_filter: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe('Optional scope to filter endpoints (e.g. "read_orders")'),
|
|
59
|
+
}),
|
|
60
|
+
handler: (input) => getApiReference(input),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'get_scope_endpoint_map',
|
|
64
|
+
description: 'Given a list of scopes, returns exactly which API endpoints are unlocked, in controller_order. ' +
|
|
65
|
+
'This is the primary tool for code generation — it tells you exactly what endpoints to generate. ' +
|
|
66
|
+
'Handles scope inheritance automatically (e.g. write_orders includes read_orders endpoints). ' +
|
|
67
|
+
'MANDATORY before generating any backend code — do not guess which endpoints a scope grants.',
|
|
68
|
+
inputSchema: z.object({
|
|
69
|
+
scopes: z
|
|
70
|
+
.array(z.string())
|
|
71
|
+
.min(1)
|
|
72
|
+
.describe('Array of OAuth scopes (e.g. ["read_orders", "write_products"])'),
|
|
73
|
+
}),
|
|
74
|
+
handler: (input) => getScopeEndpointMap(input),
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'validate_api_code',
|
|
78
|
+
description: 'MANDATORY: Call this tool AFTER generating any NestJS controller/service code and BEFORE writing it to disk. ' +
|
|
79
|
+
'Anti-hallucination validation layer that checks generated code against the actual API schema. ' +
|
|
80
|
+
'Checks: correct endpoints exist, correct HTTP methods, correct handler names, correct endpoint ordering, ' +
|
|
81
|
+
'and scope access (developer has permission for each endpoint). ' +
|
|
82
|
+
'Returns structured errors with suggestions for fixing. ' +
|
|
83
|
+
'If validation fails, fix the code based on the errors — do NOT write invalid code to disk.',
|
|
84
|
+
inputSchema: z.object({
|
|
85
|
+
code: z.string().describe('The generated NestJS controller or service code as a string'),
|
|
86
|
+
resource: z.string().describe('Resource name the code is for (e.g. "orders")'),
|
|
87
|
+
scopes: z
|
|
88
|
+
.array(z.string())
|
|
89
|
+
.min(1)
|
|
90
|
+
.describe('The scopes the developer has requested (e.g. ["read_orders"])'),
|
|
91
|
+
}),
|
|
92
|
+
handler: (input) => validateApiCode(input),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'get_webhook_events',
|
|
96
|
+
description: 'MANDATORY: Call this tool before answering ANY question about available webhook events, ' +
|
|
97
|
+
'webhook verification methods, or retry policies. Do NOT guess webhook event names or verification details. ' +
|
|
98
|
+
'Returns available webhook events for the Ratio platform. ' +
|
|
99
|
+
'Optionally filter by resource (e.g. "orders", "products"). ' +
|
|
100
|
+
'Includes verification method (HMAC-SHA256) and retry policy information.',
|
|
101
|
+
inputSchema: z.object({
|
|
102
|
+
resource: z
|
|
103
|
+
.string()
|
|
104
|
+
.optional()
|
|
105
|
+
.describe('Optional resource to filter events (e.g. "orders", "products")'),
|
|
106
|
+
}),
|
|
107
|
+
handler: (input) => getWebhookEvents(input),
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9C;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAqB;IACzC;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,kHAAkH;YAClH,2EAA2E;YAC3E,yGAAyG;YACzG,6EAA6E;YAC7E,4FAA4F;QAC9F,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,wFAAwF,CAAC;YAC3H,QAAQ,EAAE,CAAC;iBACR,IAAI,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;iBAC5C,QAAQ,EAAE;iBACV,QAAQ,CAAC,wCAAwC,CAAC;SACtD,CAAC;QACF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAA6C,CAAC;KAC9E;IACD;QACE,IAAI,EAAE,sB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