@dawmatt/api-grade-mcp 0.1.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/README.md +128 -0
- package/dist/auth/entra.d.ts +8 -0
- package/dist/auth/entra.d.ts.map +1 -0
- package/dist/auth/entra.js +59 -0
- package/dist/auth/entra.js.map +1 -0
- package/dist/auth/github.d.ts +10 -0
- package/dist/auth/github.d.ts.map +1 -0
- package/dist/auth/github.js +42 -0
- package/dist/auth/github.js.map +1 -0
- package/dist/config/resolve-ruleset.d.ts +3 -0
- package/dist/config/resolve-ruleset.d.ts.map +1 -0
- package/dist/config/resolve-ruleset.js +31 -0
- package/dist/config/resolve-ruleset.js.map +1 -0
- package/dist/config/ruleset-config.d.ts +13 -0
- package/dist/config/ruleset-config.d.ts.map +1 -0
- package/dist/config/ruleset-config.js +49 -0
- package/dist/config/ruleset-config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/assert-grade.d.ts +4 -0
- package/dist/tools/assert-grade.d.ts.map +1 -0
- package/dist/tools/assert-grade.js +132 -0
- package/dist/tools/assert-grade.js.map +1 -0
- package/dist/tools/configure-ruleset.d.ts +4 -0
- package/dist/tools/configure-ruleset.d.ts.map +1 -0
- package/dist/tools/configure-ruleset.js +94 -0
- package/dist/tools/configure-ruleset.js.map +1 -0
- package/dist/tools/get-ruleset-config.d.ts +4 -0
- package/dist/tools/get-ruleset-config.d.ts.map +1 -0
- package/dist/tools/get-ruleset-config.js +53 -0
- package/dist/tools/get-ruleset-config.js.map +1 -0
- package/dist/tools/grade-detailed.d.ts +4 -0
- package/dist/tools/grade-detailed.d.ts.map +1 -0
- package/dist/tools/grade-detailed.js +143 -0
- package/dist/tools/grade-detailed.js.map +1 -0
- package/dist/tools/grade.d.ts +4 -0
- package/dist/tools/grade.d.ts.map +1 -0
- package/dist/tools/grade.js +134 -0
- package/dist/tools/grade.js.map +1 -0
- package/dist/tools/non-breaking.d.ts +4 -0
- package/dist/tools/non-breaking.d.ts.map +1 -0
- package/dist/tools/non-breaking.js +138 -0
- package/dist/tools/non-breaking.js.map +1 -0
- package/dist/tools/quick-fixes-only.d.ts +4 -0
- package/dist/tools/quick-fixes-only.d.ts.map +1 -0
- package/dist/tools/quick-fixes-only.js +138 -0
- package/dist/tools/quick-fixes-only.js.map +1 -0
- package/dist/tools/set-ruleset-config.d.ts +4 -0
- package/dist/tools/set-ruleset-config.d.ts.map +1 -0
- package/dist/tools/set-ruleset-config.js +94 -0
- package/dist/tools/set-ruleset-config.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/classify.d.ts +14 -0
- package/dist/utils/classify.d.ts.map +1 -0
- package/dist/utils/classify.js +123 -0
- package/dist/utils/classify.js.map +1 -0
- package/dist/utils/errors.d.ts +33 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +56 -0
- package/dist/utils/errors.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const ERROR_CODES: {
|
|
2
|
+
readonly SPEC_NOT_FOUND: "SPEC_NOT_FOUND";
|
|
3
|
+
readonly SPEC_PARSE_ERROR: "SPEC_PARSE_ERROR";
|
|
4
|
+
readonly RULESET_NOT_FOUND: "RULESET_NOT_FOUND";
|
|
5
|
+
readonly INVALID_GRADE: "INVALID_GRADE";
|
|
6
|
+
readonly GRADE_ENGINE_ERROR: "GRADE_ENGINE_ERROR";
|
|
7
|
+
readonly RULESET_AUTH_FAILED: "RULESET_AUTH_FAILED";
|
|
8
|
+
readonly ENTRA_AUTH_REQUIRED: "ENTRA_AUTH_REQUIRED";
|
|
9
|
+
readonly INVALID_AUTH_CONFIG: "INVALID_AUTH_CONFIG";
|
|
10
|
+
readonly CONFIG_WRITE_ERROR: "CONFIG_WRITE_ERROR";
|
|
11
|
+
readonly REQUEST_CANCELLED: "REQUEST_CANCELLED";
|
|
12
|
+
};
|
|
13
|
+
export type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
14
|
+
export interface McpErrorResponse {
|
|
15
|
+
error: ErrorCode;
|
|
16
|
+
message: string;
|
|
17
|
+
input: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export declare function mcpError(code: ErrorCode, message: string, input: Record<string, unknown>): {
|
|
20
|
+
content: [{
|
|
21
|
+
type: 'text';
|
|
22
|
+
text: string;
|
|
23
|
+
}];
|
|
24
|
+
isError: true;
|
|
25
|
+
};
|
|
26
|
+
export declare function buildAuthFailureResponse(failureReason: string, rulesetUrl: string, scope: string, message: string): {
|
|
27
|
+
content: [{
|
|
28
|
+
type: 'text';
|
|
29
|
+
text: string;
|
|
30
|
+
}];
|
|
31
|
+
isError: true;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B;IAAE,OAAO,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,CAM9D;AAyBD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd;IAAE,OAAO,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,CAa9D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const ERROR_CODES = {
|
|
2
|
+
SPEC_NOT_FOUND: 'SPEC_NOT_FOUND',
|
|
3
|
+
SPEC_PARSE_ERROR: 'SPEC_PARSE_ERROR',
|
|
4
|
+
RULESET_NOT_FOUND: 'RULESET_NOT_FOUND',
|
|
5
|
+
INVALID_GRADE: 'INVALID_GRADE',
|
|
6
|
+
GRADE_ENGINE_ERROR: 'GRADE_ENGINE_ERROR',
|
|
7
|
+
RULESET_AUTH_FAILED: 'RULESET_AUTH_FAILED',
|
|
8
|
+
ENTRA_AUTH_REQUIRED: 'ENTRA_AUTH_REQUIRED',
|
|
9
|
+
INVALID_AUTH_CONFIG: 'INVALID_AUTH_CONFIG',
|
|
10
|
+
CONFIG_WRITE_ERROR: 'CONFIG_WRITE_ERROR',
|
|
11
|
+
REQUEST_CANCELLED: 'REQUEST_CANCELLED',
|
|
12
|
+
};
|
|
13
|
+
export function mcpError(code, message, input) {
|
|
14
|
+
const body = { error: code, message, input };
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: 'text', text: JSON.stringify(body) }],
|
|
17
|
+
isError: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const RECOVERY_OPTIONS = [
|
|
21
|
+
{
|
|
22
|
+
id: 'retry',
|
|
23
|
+
label: 'Retry',
|
|
24
|
+
description: 'Attempt to fetch the ruleset again (re-run this grading request using the configured default).',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'use-builtin-once',
|
|
28
|
+
label: 'Use built-in default for this request',
|
|
29
|
+
description: 'Grade using the built-in api-grade ruleset for this one request only. The configured default remains active for future requests.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'use-builtin-session',
|
|
33
|
+
label: 'Use built-in default for this session',
|
|
34
|
+
description: 'Grade using the built-in api-grade ruleset for all remaining requests this session. The configured default is not changed.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'cancel',
|
|
38
|
+
label: 'Cancel',
|
|
39
|
+
description: 'Cancel this grading request without returning a result.',
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
export function buildAuthFailureResponse(failureReason, rulesetUrl, scope, message) {
|
|
43
|
+
const body = {
|
|
44
|
+
error: ERROR_CODES.RULESET_AUTH_FAILED,
|
|
45
|
+
failureReason,
|
|
46
|
+
rulesetUrl,
|
|
47
|
+
scope,
|
|
48
|
+
message,
|
|
49
|
+
recoveryOptions: RECOVERY_OPTIONS,
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: 'text', text: JSON.stringify(body) }],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,cAAc,EAAE,gBAAgB;IAChC,gBAAgB,EAAE,kBAAkB;IACpC,iBAAiB,EAAE,mBAAmB;IACtC,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;IAC1C,mBAAmB,EAAE,qBAAqB;I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,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dawmatt/api-grade-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server exposing api-grade capabilities for LLMs and agentic AI tooling",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api",
|
|
7
|
+
"openapi",
|
|
8
|
+
"asyncapi",
|
|
9
|
+
"spectral",
|
|
10
|
+
"quality",
|
|
11
|
+
"grading",
|
|
12
|
+
"mcp",
|
|
13
|
+
"model-context-protocol",
|
|
14
|
+
"ai"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/DawMatt/api-grade.git"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/DawMatt/api-grade/tree/main/packages/api-grade-mcp#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/DawMatt/api-grade/issues"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"bin": {
|
|
27
|
+
"api-grade-mcp": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/server.d.ts",
|
|
32
|
+
"default": "./dist/server.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"test:watch": "vitest",
|
|
39
|
+
"test:coverage": "vitest run --coverage",
|
|
40
|
+
"lint": "eslint src",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@azure/msal-node": "^2.16.2",
|
|
45
|
+
"@dawmatt/api-grade-core": "*",
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
47
|
+
"zod": "^3.22.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.12.0",
|
|
51
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
52
|
+
"typescript": "^5.4.5",
|
|
53
|
+
"vitest": "^1.6.0"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=20.0.0"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist"
|
|
60
|
+
]
|
|
61
|
+
}
|