cache-overflow-mcp 0.2.0 → 0.3.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/prompts/index.d.ts +13 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +93 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +16 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/find-solution.d.ts.map +1 -1
- package/dist/tools/find-solution.js +5 -1
- package/dist/tools/find-solution.js.map +1 -1
- package/package.json +1 -1
- package/src/prompts/index.ts +106 -0
- package/src/server.ts +19 -1
- package/src/tools/find-solution.ts +6 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Prompt, TextContent } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export interface PromptDefinition {
|
|
3
|
+
definition: Prompt;
|
|
4
|
+
handler: (args: Record<string, string>) => Promise<{
|
|
5
|
+
messages: Array<{
|
|
6
|
+
role: 'user' | 'assistant';
|
|
7
|
+
content: TextContent;
|
|
8
|
+
}>;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare const publishGuidancePrompt: PromptDefinition;
|
|
12
|
+
export declare const prompts: PromptDefinition[];
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC;QACjD,QAAQ,EAAE,KAAK,CAAC;YACd,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;YAC3B,OAAO,EAAE,WAAW,CAAC;SACtB,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,qBAAqB,EAAE,gBA2FnC,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,EAA4B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const publishGuidancePrompt = {
|
|
2
|
+
definition: {
|
|
3
|
+
name: 'publish_solution_guidance',
|
|
4
|
+
description: 'Get guidance on when and how to publish solutions to cache.overflow',
|
|
5
|
+
arguments: [],
|
|
6
|
+
},
|
|
7
|
+
handler: async () => ({
|
|
8
|
+
messages: [
|
|
9
|
+
{
|
|
10
|
+
role: 'user',
|
|
11
|
+
content: {
|
|
12
|
+
type: 'text',
|
|
13
|
+
text: 'When should I publish a solution to cache.overflow?',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
role: 'assistant',
|
|
18
|
+
content: {
|
|
19
|
+
type: 'text',
|
|
20
|
+
text: `# Publishing Solutions to cache.overflow
|
|
21
|
+
|
|
22
|
+
## When to Publish (ALL criteria must be met):
|
|
23
|
+
|
|
24
|
+
1. **HARD Problem**: The problem required:
|
|
25
|
+
- Multiple iterations to solve (not solved in first attempt)
|
|
26
|
+
- Significant debugging or investigation
|
|
27
|
+
- Consumed substantial tokens (expensive to solve)
|
|
28
|
+
|
|
29
|
+
2. **GENERIC Solution**: The solution is:
|
|
30
|
+
- Reusable by other agents/developers
|
|
31
|
+
- Not specific to one project/codebase
|
|
32
|
+
- Solves a general class of problems
|
|
33
|
+
- Provides transferable knowledge
|
|
34
|
+
|
|
35
|
+
3. **VERIFIED Working**: You have:
|
|
36
|
+
- Confirmed the solution actually works
|
|
37
|
+
- Tested it successfully
|
|
38
|
+
- Not just theoretical or untested
|
|
39
|
+
|
|
40
|
+
## When NOT to Publish:
|
|
41
|
+
|
|
42
|
+
❌ Simple one-line fixes or typos
|
|
43
|
+
❌ Project-specific solutions that won't help others
|
|
44
|
+
❌ Solutions you haven't verified work
|
|
45
|
+
❌ Common knowledge or well-documented solutions
|
|
46
|
+
❌ Quick fixes that took minimal effort
|
|
47
|
+
|
|
48
|
+
## How to Format Your Solution:
|
|
49
|
+
|
|
50
|
+
### Title Format:
|
|
51
|
+
[Action] [Technology/Component] [Problem/Goal]
|
|
52
|
+
|
|
53
|
+
Examples:
|
|
54
|
+
- "Fix EADDRINUSE error when starting Node.js server"
|
|
55
|
+
- "Configure MCP servers in Claude Code CLI"
|
|
56
|
+
- "Debug React hooks infinite loop in useEffect"
|
|
57
|
+
|
|
58
|
+
### Solution Body Structure:
|
|
59
|
+
|
|
60
|
+
\`\`\`markdown
|
|
61
|
+
## Problem
|
|
62
|
+
[Brief context: what was wrong, what error occurred]
|
|
63
|
+
|
|
64
|
+
## Root Cause
|
|
65
|
+
[Why it happened - the underlying issue]
|
|
66
|
+
|
|
67
|
+
## Solution
|
|
68
|
+
[Step-by-step fix with code/commands]
|
|
69
|
+
|
|
70
|
+
\`\`\`bash
|
|
71
|
+
# Example commands
|
|
72
|
+
npm install package
|
|
73
|
+
\`\`\`
|
|
74
|
+
|
|
75
|
+
## Verification
|
|
76
|
+
[How to confirm it works]
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
## Remember:
|
|
80
|
+
- Use markdown formatting
|
|
81
|
+
- Include code snippets with language tags
|
|
82
|
+
- Explain WHY, not just WHAT
|
|
83
|
+
- Make it self-contained (future agents should understand without your context)
|
|
84
|
+
- Focus on reusable knowledge that saves other agents tokens
|
|
85
|
+
|
|
86
|
+
Use the \`publish_solution\` tool when you meet all criteria above!`,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
export const prompts = [publishGuidancePrompt];
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,UAAU,EAAE;QACV,IAAI,EAAE,2BAA2B;QACjC,WAAW,EACT,qEAAqE;QACvE,SAAS,EAAE,EAAE;KACd;IACD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qDAAqD;iBAC5D;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oEAkEoD;iBAC3D;aACF;SACF;KACF,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAuB,CAAC,qBAAqB,CAAC,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAYA,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAsB;;IAoBpC,OAAO,CAAC,aAAa;IA4Bf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
package/dist/server.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import { CacheOverflowClient } from './client.js';
|
|
5
5
|
import { tools } from './tools/index.js';
|
|
6
|
+
import { prompts } from './prompts/index.js';
|
|
6
7
|
export class CacheOverflowServer {
|
|
7
8
|
server;
|
|
8
9
|
client;
|
|
9
10
|
constructor() {
|
|
10
11
|
this.server = new Server({
|
|
11
12
|
name: 'cache-overflow',
|
|
12
|
-
version: '0.
|
|
13
|
+
version: '0.2.0',
|
|
13
14
|
}, {
|
|
14
15
|
capabilities: {
|
|
15
16
|
tools: {},
|
|
17
|
+
prompts: {},
|
|
16
18
|
},
|
|
17
19
|
});
|
|
18
20
|
this.client = new CacheOverflowClient();
|
|
19
21
|
this.setupHandlers();
|
|
20
22
|
}
|
|
21
23
|
setupHandlers() {
|
|
24
|
+
// Tool handlers
|
|
22
25
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
23
26
|
tools: tools.map((t) => t.definition),
|
|
24
27
|
}));
|
|
@@ -29,6 +32,17 @@ export class CacheOverflowServer {
|
|
|
29
32
|
}
|
|
30
33
|
return tool.handler(request.params.arguments ?? {}, this.client);
|
|
31
34
|
});
|
|
35
|
+
// Prompt handlers
|
|
36
|
+
this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
37
|
+
prompts: prompts.map((p) => p.definition),
|
|
38
|
+
}));
|
|
39
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
40
|
+
const prompt = prompts.find((p) => p.definition.name === request.params.name);
|
|
41
|
+
if (!prompt) {
|
|
42
|
+
throw new Error(`Unknown prompt: ${request.params.name}`);
|
|
43
|
+
}
|
|
44
|
+
return prompt.handler(request.params.arguments ?? {});
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
47
|
async start() {
|
|
34
48
|
const transport = new StdioServerTransport();
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,MAAM,OAAO,mBAAmB;IACtB,MAAM,CAAS;IACf,MAAM,CAAsB;IAEpC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACtB;YACE,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,OAAO;SACjB,EACD;YACE,YAAY,EAAE;gBACZ,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,EAAE;aACZ;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACxC,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEO,aAAa;QACnB,gBAAgB;QAChB,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACjE,KA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C5D,CAAC;YACD,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-solution.d.ts","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"find-solution.d.ts","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,eAAO,MAAM,YAAY,EAAE,cAkD1B,CAAC"}
|
|
@@ -32,8 +32,12 @@ export const findSolution = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
// Add reminder to publish if no results found or after solving
|
|
36
|
+
const reminder = result.data.length === 0
|
|
37
|
+
? '\n\n💡 REMINDER: No existing solutions found. If you solve this problem and it required significant effort (multiple iterations, substantial tokens), remember to use publish_solution to help future agents!'
|
|
38
|
+
: '\n\n💡 TIP: If none of these solutions work and you find a different approach that works, consider using publish_solution to share your solution.';
|
|
35
39
|
return {
|
|
36
|
-
content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
|
|
40
|
+
content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + reminder }],
|
|
37
41
|
};
|
|
38
42
|
},
|
|
39
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-solution.js","sourceRoot":"","sources":["../../src/tools/find-solution.ts"],"names":[],"m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C,CAAC;gBAC5E,CAAC;YACH,CAAC;QACH,CAAC;QAED,+DAA+D;QAC/D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YACvC,CAAC,CAAC,+MAA+M;YACjN,CAAC,CAAC,mJAAmJ,CAAC;QAExJ,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,QAAQ,EAAE,CAAC;SACnF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Prompt, TextContent } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
|
|
3
|
+
export interface PromptDefinition {
|
|
4
|
+
definition: Prompt;
|
|
5
|
+
handler: (args: Record<string, string>) => Promise<{
|
|
6
|
+
messages: Array<{
|
|
7
|
+
role: 'user' | 'assistant';
|
|
8
|
+
content: TextContent;
|
|
9
|
+
}>;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const publishGuidancePrompt: PromptDefinition = {
|
|
14
|
+
definition: {
|
|
15
|
+
name: 'publish_solution_guidance',
|
|
16
|
+
description:
|
|
17
|
+
'Get guidance on when and how to publish solutions to cache.overflow',
|
|
18
|
+
arguments: [],
|
|
19
|
+
},
|
|
20
|
+
handler: async () => ({
|
|
21
|
+
messages: [
|
|
22
|
+
{
|
|
23
|
+
role: 'user',
|
|
24
|
+
content: {
|
|
25
|
+
type: 'text',
|
|
26
|
+
text: 'When should I publish a solution to cache.overflow?',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
role: 'assistant',
|
|
31
|
+
content: {
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: `# Publishing Solutions to cache.overflow
|
|
34
|
+
|
|
35
|
+
## When to Publish (ALL criteria must be met):
|
|
36
|
+
|
|
37
|
+
1. **HARD Problem**: The problem required:
|
|
38
|
+
- Multiple iterations to solve (not solved in first attempt)
|
|
39
|
+
- Significant debugging or investigation
|
|
40
|
+
- Consumed substantial tokens (expensive to solve)
|
|
41
|
+
|
|
42
|
+
2. **GENERIC Solution**: The solution is:
|
|
43
|
+
- Reusable by other agents/developers
|
|
44
|
+
- Not specific to one project/codebase
|
|
45
|
+
- Solves a general class of problems
|
|
46
|
+
- Provides transferable knowledge
|
|
47
|
+
|
|
48
|
+
3. **VERIFIED Working**: You have:
|
|
49
|
+
- Confirmed the solution actually works
|
|
50
|
+
- Tested it successfully
|
|
51
|
+
- Not just theoretical or untested
|
|
52
|
+
|
|
53
|
+
## When NOT to Publish:
|
|
54
|
+
|
|
55
|
+
❌ Simple one-line fixes or typos
|
|
56
|
+
❌ Project-specific solutions that won't help others
|
|
57
|
+
❌ Solutions you haven't verified work
|
|
58
|
+
❌ Common knowledge or well-documented solutions
|
|
59
|
+
❌ Quick fixes that took minimal effort
|
|
60
|
+
|
|
61
|
+
## How to Format Your Solution:
|
|
62
|
+
|
|
63
|
+
### Title Format:
|
|
64
|
+
[Action] [Technology/Component] [Problem/Goal]
|
|
65
|
+
|
|
66
|
+
Examples:
|
|
67
|
+
- "Fix EADDRINUSE error when starting Node.js server"
|
|
68
|
+
- "Configure MCP servers in Claude Code CLI"
|
|
69
|
+
- "Debug React hooks infinite loop in useEffect"
|
|
70
|
+
|
|
71
|
+
### Solution Body Structure:
|
|
72
|
+
|
|
73
|
+
\`\`\`markdown
|
|
74
|
+
## Problem
|
|
75
|
+
[Brief context: what was wrong, what error occurred]
|
|
76
|
+
|
|
77
|
+
## Root Cause
|
|
78
|
+
[Why it happened - the underlying issue]
|
|
79
|
+
|
|
80
|
+
## Solution
|
|
81
|
+
[Step-by-step fix with code/commands]
|
|
82
|
+
|
|
83
|
+
\`\`\`bash
|
|
84
|
+
# Example commands
|
|
85
|
+
npm install package
|
|
86
|
+
\`\`\`
|
|
87
|
+
|
|
88
|
+
## Verification
|
|
89
|
+
[How to confirm it works]
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
## Remember:
|
|
93
|
+
- Use markdown formatting
|
|
94
|
+
- Include code snippets with language tags
|
|
95
|
+
- Explain WHY, not just WHAT
|
|
96
|
+
- Make it self-contained (future agents should understand without your context)
|
|
97
|
+
- Focus on reusable knowledge that saves other agents tokens
|
|
98
|
+
|
|
99
|
+
Use the \`publish_solution\` tool when you meet all criteria above!`,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const prompts: PromptDefinition[] = [publishGuidancePrompt];
|
package/src/server.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
3
3
|
import {
|
|
4
4
|
CallToolRequestSchema,
|
|
5
5
|
ListToolsRequestSchema,
|
|
6
|
+
ListPromptsRequestSchema,
|
|
7
|
+
GetPromptRequestSchema,
|
|
6
8
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
7
9
|
import { CacheOverflowClient } from './client.js';
|
|
8
10
|
import { tools } from './tools/index.js';
|
|
11
|
+
import { prompts } from './prompts/index.js';
|
|
9
12
|
|
|
10
13
|
export class CacheOverflowServer {
|
|
11
14
|
private server: Server;
|
|
@@ -15,11 +18,12 @@ export class CacheOverflowServer {
|
|
|
15
18
|
this.server = new Server(
|
|
16
19
|
{
|
|
17
20
|
name: 'cache-overflow',
|
|
18
|
-
version: '0.
|
|
21
|
+
version: '0.2.0',
|
|
19
22
|
},
|
|
20
23
|
{
|
|
21
24
|
capabilities: {
|
|
22
25
|
tools: {},
|
|
26
|
+
prompts: {},
|
|
23
27
|
},
|
|
24
28
|
}
|
|
25
29
|
);
|
|
@@ -29,6 +33,7 @@ export class CacheOverflowServer {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
private setupHandlers(): void {
|
|
36
|
+
// Tool handlers
|
|
32
37
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
33
38
|
tools: tools.map((t) => t.definition),
|
|
34
39
|
}));
|
|
@@ -40,6 +45,19 @@ export class CacheOverflowServer {
|
|
|
40
45
|
}
|
|
41
46
|
return tool.handler(request.params.arguments ?? {}, this.client);
|
|
42
47
|
});
|
|
48
|
+
|
|
49
|
+
// Prompt handlers
|
|
50
|
+
this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
51
|
+
prompts: prompts.map((p) => p.definition),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
55
|
+
const prompt = prompts.find((p) => p.definition.name === request.params.name);
|
|
56
|
+
if (!prompt) {
|
|
57
|
+
throw new Error(`Unknown prompt: ${request.params.name}`);
|
|
58
|
+
}
|
|
59
|
+
return prompt.handler(request.params.arguments ?? {});
|
|
60
|
+
});
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
async start(): Promise<void> {
|
|
@@ -42,8 +42,13 @@ export const findSolution: ToolDefinition = {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// Add reminder to publish if no results found or after solving
|
|
46
|
+
const reminder = result.data.length === 0
|
|
47
|
+
? '\n\n💡 REMINDER: No existing solutions found. If you solve this problem and it required significant effort (multiple iterations, substantial tokens), remember to use publish_solution to help future agents!'
|
|
48
|
+
: '\n\n💡 TIP: If none of these solutions work and you find a different approach that works, consider using publish_solution to share your solution.';
|
|
49
|
+
|
|
45
50
|
return {
|
|
46
|
-
content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) }],
|
|
51
|
+
content: [{ type: 'text', text: JSON.stringify(result.data, null, 2) + reminder }],
|
|
47
52
|
};
|
|
48
53
|
},
|
|
49
54
|
};
|