claude-orator-mcp 0.2.0 → 0.2.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.js +18 -43
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* and applies Anthropic's prompt engineering techniques to produce an optimized scaffold.
|
|
6
6
|
*/
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
|
-
import {
|
|
8
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
-
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
11
10
|
import { fmt, fmtMinimal } from './format.js';
|
|
12
11
|
import { optimize } from './optimize.js';
|
|
13
12
|
import { clientSupportsSampling, validateViaSampling } from './sampling.js';
|
|
@@ -43,54 +42,30 @@ The \`analysis\` field provides enriched analysis for programmatic consumption:
|
|
|
43
42
|
- **semantic_hints**: Meta-observations about analysis uncertainty. Treat as a review checklist, not issues. Verify with the user when intent is ambiguous.
|
|
44
43
|
- **dimension_scores**: Raw 7-dimension breakdown (clarity, specificity, structure, examples, constraints, output_format, token_efficiency). Each 0-10.
|
|
45
44
|
- **sampling_used**: Whether a second-opinion was obtained via MCP sampling. Check \`sampling_validation\` for details when true.`;
|
|
46
|
-
// ---
|
|
47
|
-
const
|
|
48
|
-
name: '
|
|
45
|
+
// --- Server setup ---
|
|
46
|
+
const server = new McpServer({
|
|
47
|
+
name: 'claude-orator-mcp',
|
|
48
|
+
version: SERVER_VERSION,
|
|
49
|
+
title: 'Claude Orator',
|
|
50
|
+
description: 'Prompt optimization using Anthropic best practices',
|
|
51
|
+
}, { instructions: SERVER_INSTRUCTIONS });
|
|
52
|
+
server.registerTool('orator_optimize', {
|
|
53
|
+
title: 'Optimize Prompt',
|
|
49
54
|
description: 'Analyze and optimize a prompt using Anthropic best practices. Returns an optimized prompt scaffold with score metrics, detected issues, and applied techniques.',
|
|
50
55
|
inputSchema: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
description: 'The raw prompt to optimize',
|
|
56
|
-
},
|
|
57
|
-
intent: {
|
|
58
|
-
type: 'string',
|
|
59
|
-
enum: ['code', 'analysis', 'creative', 'extraction', 'conversation', 'system'],
|
|
60
|
-
description: 'Intent category (auto-detected if omitted)',
|
|
61
|
-
},
|
|
62
|
-
target: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
enum: ['claude-code', 'claude-api', 'claude-desktop', 'generic'],
|
|
65
|
-
description: 'Target environment for the optimized prompt (default: claude-code)',
|
|
66
|
-
},
|
|
67
|
-
techniques: {
|
|
68
|
-
type: 'array',
|
|
69
|
-
items: { type: 'string' },
|
|
70
|
-
description: 'Force-apply specific technique IDs',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
required: ['prompt'],
|
|
56
|
+
prompt: OptimizeInputSchema.shape.prompt.describe('The raw prompt to optimize'),
|
|
57
|
+
intent: OptimizeInputSchema.shape.intent.describe('Intent category (auto-detected if omitted)'),
|
|
58
|
+
target: OptimizeInputSchema.shape.target.describe('Target environment for the optimized prompt (default: claude-code)'),
|
|
59
|
+
techniques: OptimizeInputSchema.shape.techniques.describe('Force-apply specific technique IDs'),
|
|
74
60
|
},
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const server = new Server({ name: 'claude-orator-mcp', version: SERVER_VERSION }, { capabilities: { tools: {} }, instructions: SERVER_INSTRUCTIONS });
|
|
78
|
-
// List tools handler
|
|
79
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
80
|
-
tools: [optimizeToolDef],
|
|
81
|
-
}));
|
|
82
|
-
// Call tool handler
|
|
83
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
84
|
-
const { name, arguments: args } = request.params;
|
|
61
|
+
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
62
|
+
}, async (args) => {
|
|
85
63
|
try {
|
|
86
|
-
if (name !== 'orator_optimize') {
|
|
87
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
88
|
-
}
|
|
89
64
|
const input = OptimizeInputSchema.parse(args);
|
|
90
65
|
const result = optimize(input);
|
|
91
66
|
// Sampling validation: ask host LLM to review analysis if it supports sampling
|
|
92
|
-
if (result.analysis?.semantic_hints.length && clientSupportsSampling(server)) {
|
|
93
|
-
const validation = await validateViaSampling(server, result, result.analysis.semantic_hints);
|
|
67
|
+
if (result.analysis?.semantic_hints.length && clientSupportsSampling(server.server)) {
|
|
68
|
+
const validation = await validateViaSampling(server.server, result, result.analysis.semantic_hints);
|
|
94
69
|
if (validation && result.analysis) {
|
|
95
70
|
result.analysis.sampling_used = true;
|
|
96
71
|
result.analysis.sampling_validation = validation;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM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AAO,EAAE,EAAE,CAAC;YACtD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CACF,CAAC;AAEF,sBAAsB;AAEtB,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,eAAe,cAAc,mBAAmB,CAAC,CAAC;AAClE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-orator-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "An MCP server for prompt optimization in Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js"
|
|
10
|
+
},
|
|
7
11
|
"bin": {
|
|
8
12
|
"claude-orator-mcp": "./dist/index.js"
|
|
9
13
|
},
|
|
@@ -72,7 +76,7 @@
|
|
|
72
76
|
"node": ">=20.0.0"
|
|
73
77
|
},
|
|
74
78
|
"dependencies": {
|
|
75
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
79
|
+
"@modelcontextprotocol/sdk": "^1.27.0",
|
|
76
80
|
"zod": "^4.1.13"
|
|
77
81
|
},
|
|
78
82
|
"devDependencies": {
|