@ratio-mcp/docs-server 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/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/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 +73 -0
- package/dist/tools/get-scopes.d.ts.map +1 -0
- package/dist/tools/get-scopes.js +74 -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 +85 -0
- package/dist/tools/index.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 +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +52 -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,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/shared").EndpointParam[];
|
|
48
|
+
path_params: import("@ratio-mcp/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,2B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Q,EAAE,MAAM,CAAC,QAAQ;QACzB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,cAAc,EAAE,SAAS,CAAC,MAAM;QAChC,SAAS,EAAE,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/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,mBAAmB,CAAC;AA6B9D;;;;;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/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1C,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,KAAK,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,IAAI,mBAAmB,EAAE,CAAC;QAC5D,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,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get_available_scopes — Returns all available scopes grouped by primary resource.
|
|
3
|
+
* Now returns enriched data: scope descriptions, use_cases, commonly_paired_with,
|
|
4
|
+
* plus resource-level metadata (description, codegen_ready, example_app_types).
|
|
5
|
+
*
|
|
6
|
+
* This enriched data allows the LLM to intelligently suggest scopes based on
|
|
7
|
+
* a developer's app description, without needing a separate recommendation tool.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAvailableScopes(input: {
|
|
10
|
+
resource?: string;
|
|
11
|
+
}): {
|
|
12
|
+
error: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
available_resources: ("orders" | "products" | "customers" | "inventory" | "discounts" | "payments" | "shipping" | "fulfillments" | "draft_orders" | "returns" | "gift_cards" | "analytics" | "channels" | "content" | "files" | "locations" | "themes" | "markets" | "reports" | "locales" | "publications" | "settings" | "webhooks" | "apps")[];
|
|
15
|
+
resource?: undefined;
|
|
16
|
+
resource_info?: undefined;
|
|
17
|
+
scopes?: undefined;
|
|
18
|
+
total?: undefined;
|
|
19
|
+
total_resources?: undefined;
|
|
20
|
+
total_scopes?: undefined;
|
|
21
|
+
resources?: undefined;
|
|
22
|
+
_instruction?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
resource: string;
|
|
25
|
+
resource_info: {
|
|
26
|
+
description: string;
|
|
27
|
+
codegen_ready: boolean;
|
|
28
|
+
commonly_needed_with: string[] | undefined;
|
|
29
|
+
example_app_types: string[] | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
scopes: {
|
|
32
|
+
code: string;
|
|
33
|
+
label: string;
|
|
34
|
+
description: string;
|
|
35
|
+
use_cases: string[];
|
|
36
|
+
commonly_paired_with: string[] | undefined;
|
|
37
|
+
}[];
|
|
38
|
+
total: number;
|
|
39
|
+
error?: undefined;
|
|
40
|
+
message?: undefined;
|
|
41
|
+
available_resources?: undefined;
|
|
42
|
+
total_resources?: undefined;
|
|
43
|
+
total_scopes?: undefined;
|
|
44
|
+
resources?: undefined;
|
|
45
|
+
_instruction?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
total_resources: number;
|
|
48
|
+
total_scopes: number;
|
|
49
|
+
resources: {
|
|
50
|
+
resource: "orders" | "products" | "customers" | "inventory" | "discounts" | "payments" | "shipping" | "fulfillments" | "draft_orders" | "returns" | "gift_cards" | "analytics" | "channels" | "content" | "files" | "locations" | "themes" | "markets" | "reports" | "locales" | "publications" | "settings" | "webhooks" | "apps";
|
|
51
|
+
description: string;
|
|
52
|
+
codegen_ready: boolean;
|
|
53
|
+
commonly_needed_with: string[];
|
|
54
|
+
example_app_types: string[];
|
|
55
|
+
scopes: {
|
|
56
|
+
code: string;
|
|
57
|
+
label: string;
|
|
58
|
+
description: string;
|
|
59
|
+
use_cases: string[];
|
|
60
|
+
commonly_paired_with: string[] | undefined;
|
|
61
|
+
}[];
|
|
62
|
+
count: number;
|
|
63
|
+
}[];
|
|
64
|
+
_instruction: string;
|
|
65
|
+
error?: undefined;
|
|
66
|
+
message?: undefined;
|
|
67
|
+
available_resources?: undefined;
|
|
68
|
+
resource?: undefined;
|
|
69
|
+
resource_info?: undefined;
|
|
70
|
+
scopes?: undefined;
|
|
71
|
+
total?: undefined;
|
|
72
|
+
};
|
|
73
|
+
//# 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;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqE9D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SCOPES_BY_RESOURCE, PRIMARY_RESOURCES, RESOURCE_METADATA } from '@ratio-mcp/shared';
|
|
2
|
+
/**
|
|
3
|
+
* get_available_scopes — Returns all available scopes grouped by primary resource.
|
|
4
|
+
* Now returns enriched data: scope descriptions, use_cases, commonly_paired_with,
|
|
5
|
+
* plus resource-level metadata (description, codegen_ready, example_app_types).
|
|
6
|
+
*
|
|
7
|
+
* This enriched data allows the LLM to intelligently suggest scopes based on
|
|
8
|
+
* a developer's app description, without needing a separate recommendation tool.
|
|
9
|
+
*/
|
|
10
|
+
export function getAvailableScopes(input) {
|
|
11
|
+
if (input.resource) {
|
|
12
|
+
const resourceScopes = SCOPES_BY_RESOURCE[input.resource];
|
|
13
|
+
const resourceMeta = RESOURCE_METADATA[input.resource];
|
|
14
|
+
if (!resourceScopes) {
|
|
15
|
+
return {
|
|
16
|
+
error: true,
|
|
17
|
+
message: `Unknown resource: "${input.resource}"`,
|
|
18
|
+
available_resources: [...PRIMARY_RESOURCES],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
resource: input.resource,
|
|
23
|
+
resource_info: resourceMeta
|
|
24
|
+
? {
|
|
25
|
+
description: resourceMeta.description,
|
|
26
|
+
codegen_ready: resourceMeta.codegen_ready,
|
|
27
|
+
commonly_needed_with: resourceMeta.commonly_needed_with,
|
|
28
|
+
example_app_types: resourceMeta.example_app_types,
|
|
29
|
+
}
|
|
30
|
+
: undefined,
|
|
31
|
+
scopes: resourceScopes.map((s) => ({
|
|
32
|
+
code: s.code,
|
|
33
|
+
label: s.label,
|
|
34
|
+
description: s.description,
|
|
35
|
+
use_cases: s.use_cases,
|
|
36
|
+
commonly_paired_with: s.commonly_paired_with,
|
|
37
|
+
})),
|
|
38
|
+
total: resourceScopes.length,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Return all primary resources with their scopes and metadata
|
|
42
|
+
const resources = PRIMARY_RESOURCES.map((resourceName) => {
|
|
43
|
+
const scopes = SCOPES_BY_RESOURCE[resourceName] || [];
|
|
44
|
+
const meta = RESOURCE_METADATA[resourceName];
|
|
45
|
+
return {
|
|
46
|
+
resource: resourceName,
|
|
47
|
+
description: meta?.description || '',
|
|
48
|
+
codegen_ready: meta?.codegen_ready || false,
|
|
49
|
+
commonly_needed_with: meta?.commonly_needed_with || [],
|
|
50
|
+
example_app_types: meta?.example_app_types || [],
|
|
51
|
+
scopes: scopes.map((s) => ({
|
|
52
|
+
code: s.code,
|
|
53
|
+
label: s.label,
|
|
54
|
+
description: s.description,
|
|
55
|
+
use_cases: s.use_cases,
|
|
56
|
+
commonly_paired_with: s.commonly_paired_with,
|
|
57
|
+
})),
|
|
58
|
+
count: scopes.length,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
total_resources: resources.length,
|
|
63
|
+
total_scopes: resources.reduce((sum, r) => sum + r.count, 0),
|
|
64
|
+
resources,
|
|
65
|
+
_instruction: 'Use the resource descriptions, scope descriptions, use_cases, and commonly_paired_with fields ' +
|
|
66
|
+
'to intelligently suggest scopes based on what the developer wants to build. ' +
|
|
67
|
+
'Present primary scopes as pre-selected recommendations, and related scopes as optional additions. ' +
|
|
68
|
+
'Always explain WHY each scope is recommended for their specific app. ' +
|
|
69
|
+
'Note: codegen_ready=true means generate_api_routes can auto-generate backend code for that resource. ' +
|
|
70
|
+
'After selecting scopes, call define_app_requirements WITHOUT confirmed=true first to get a preview, ' +
|
|
71
|
+
'then show it to the developer for approval before calling with confirmed=true.',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
//# 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,MAAM,mBAAmB,CAAC;AAE7F;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA4B;IAC7D,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,cAAc,GAAG,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,sBAAsB,KAAK,CAAC,QAAQ,GAAG;gBAChD,mBAA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AI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;aAC7C,CAAC,CAAC;YACH,KAAK,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC;IACJ,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,gGAAgG;YAChG,8EAA8E;YAC9E,oGAAoG;YACpG,uEAAuE;YACvE,uGAAuG;YACvG,sGAAsG;YACtG,gFAAgF;KACnF,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":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C,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 (5 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;AAOxB;;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,EAgFrC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* All docs-server tools (5 tools)
|
|
9
|
+
*/
|
|
10
|
+
export const docsTools = [
|
|
11
|
+
{
|
|
12
|
+
name: 'get_available_scopes',
|
|
13
|
+
description: 'Returns all available OAuth scopes grouped by resource. ' +
|
|
14
|
+
'Use when a developer says what kind of app they want to build — show them available scopes to pick from. ' +
|
|
15
|
+
'Optionally filter by resource name (e.g. "orders", "products", "customers"). ' +
|
|
16
|
+
'Returns 24 primary resources with their read/write/delete scopes. ' +
|
|
17
|
+
'Each scope includes a rich description, use_cases, and commonly_paired_with hints ' +
|
|
18
|
+
'so you can intelligently recommend scopes based on the developer\'s app description. ' +
|
|
19
|
+
'Each resource includes codegen_ready (whether code generation works for it) and example_app_types.',
|
|
20
|
+
inputSchema: z.object({
|
|
21
|
+
resource: z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Optional resource name to filter scopes (e.g. "orders", "customers", "discounts")'),
|
|
25
|
+
}),
|
|
26
|
+
handler: (input) => getAvailableScopes(input),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'get_api_reference',
|
|
30
|
+
description: 'Returns complete API reference for a resource including all endpoints, parameters, request/response schemas. ' +
|
|
31
|
+
'Endpoints are returned in controller_order for deterministic code generation. ' +
|
|
32
|
+
'Optionally filter by scope to show only endpoints accessible with that scope.',
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
resource: z.string().describe('Resource name (e.g. "orders", "products")'),
|
|
35
|
+
scope_filter: z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Optional scope to filter endpoints (e.g. "read_orders")'),
|
|
39
|
+
}),
|
|
40
|
+
handler: (input) => getApiReference(input),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'get_scope_endpoint_map',
|
|
44
|
+
description: 'Given a list of scopes, returns exactly which API endpoints are unlocked, in controller_order. ' +
|
|
45
|
+
'This is the primary tool for code generation — it tells you exactly what endpoints to generate. ' +
|
|
46
|
+
'Handles scope inheritance automatically (e.g. write_orders includes read_orders endpoints).',
|
|
47
|
+
inputSchema: z.object({
|
|
48
|
+
scopes: z
|
|
49
|
+
.array(z.string())
|
|
50
|
+
.min(1)
|
|
51
|
+
.describe('Array of OAuth scopes (e.g. ["read_orders", "write_products"])'),
|
|
52
|
+
}),
|
|
53
|
+
handler: (input) => getScopeEndpointMap(input),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'validate_api_code',
|
|
57
|
+
description: 'Anti-hallucination validation layer. Takes generated NestJS controller/service code as a string and validates it against the API schema. ' +
|
|
58
|
+
'Checks: correct endpoints exist, correct HTTP methods, correct handler names, correct endpoint ordering (controller_order), ' +
|
|
59
|
+
'and scope access (developer has permission for each endpoint). Returns structured errors with suggestions for fixing. ' +
|
|
60
|
+
'Call this AFTER generating backend code to verify correctness before writing to disk.',
|
|
61
|
+
inputSchema: z.object({
|
|
62
|
+
code: z.string().describe('The generated NestJS controller or service code as a string'),
|
|
63
|
+
resource: z.string().describe('Resource name the code is for (e.g. "orders")'),
|
|
64
|
+
scopes: z
|
|
65
|
+
.array(z.string())
|
|
66
|
+
.min(1)
|
|
67
|
+
.describe('The scopes the developer has requested (e.g. ["read_orders"])'),
|
|
68
|
+
}),
|
|
69
|
+
handler: (input) => validateApiCode(input),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'get_webhook_events',
|
|
73
|
+
description: 'Returns available webhook events for the Ratio platform. ' +
|
|
74
|
+
'Optionally filter by resource (e.g. "orders", "products"). ' +
|
|
75
|
+
'Includes verification method (HMAC-SHA256) and retry policy information.',
|
|
76
|
+
inputSchema: z.object({
|
|
77
|
+
resource: z
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Optional resource to filter events (e.g. "orders", "products")'),
|
|
81
|
+
}),
|
|
82
|
+
handler: (input) => getWebhookEvents(input),
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AA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layer.
|
|
4
|
+
* Takes generated NestJS controller/service code as string input, validates against the schema.
|
|
5
|
+
* Checks: correct endpoints, correct HTTP methods, correct scope annotations, correct handler order.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateApiCode(input: {
|
|
8
|
+
code: string;
|
|
9
|
+
resource: string;
|
|
10
|
+
scopes: string[];
|
|
11
|
+
}): ValidationResult;
|
|
12
|
+
//# sourceMappingURL=validate-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-code.d.ts","sourceRoot":"","sources":["../../src/tools/validate-code.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAwB3E;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,GAAG,gBAAgB,CAgLnB"}
|