mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 13:21:55 +00:00
feat(mcp-server): add Zod schema for prompt arguments, rename ask262 prompt to ask, and enhance orchestration guidance text.
This commit is contained in:
+30
-15
@@ -11,6 +11,7 @@ import * as lancedbSdk from "@lancedb/lancedb";
|
||||
import { OllamaEmbeddings } from "@langchain/ollama";
|
||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
createEvaluateInEngine262Tool,
|
||||
createGetSectionContentTool,
|
||||
@@ -192,45 +193,59 @@ export async function main() {
|
||||
|
||||
// Register prompt for tool orchestration guidance
|
||||
server.registerPrompt(
|
||||
"ask262",
|
||||
"ask",
|
||||
{
|
||||
description:
|
||||
"How to orchestrate ask262 tools to explore JavaScript internals",
|
||||
argsSchema: {
|
||||
question: z
|
||||
.string()
|
||||
.describe("Question"),
|
||||
},
|
||||
async () => ({
|
||||
},
|
||||
async ({ question }) => ({
|
||||
description: "Ask262 orchestration guide",
|
||||
messages: [
|
||||
{
|
||||
role: "user",
|
||||
content: {
|
||||
type: "text",
|
||||
text: question,
|
||||
},
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: {
|
||||
type: "text",
|
||||
text: `Ask262 helps explain how Javascript works according to ECMAScript specification.
|
||||
text: `I'll help you explore this using the ECMAScript specification. Let me orchestrate the ask262 tools to find accurate information.
|
||||
|
||||
Available tools:
|
||||
- ask262_search_spec_sections: Vector search to find relevant spec section ids
|
||||
- ask262_get_section_content: Retrieve full text from a spec section id
|
||||
- ask262_evaluate_in_engine262: Execute pure JS and capture which spec section ids are hit. Has 1-second timeout for safety.
|
||||
|
||||
Orchestration patterns:
|
||||
Based on your question: "${question}"
|
||||
|
||||
1. For "What happens when I run this code?" questions:
|
||||
- Use ask262Debug.startImportant() and ask262Debug.stopImportant() in the code to mark important sections.
|
||||
I'll use one of these orchestration patterns:
|
||||
|
||||
PATTERN 1 - For "What happens when I run this code?" questions:
|
||||
- Use ask262Debug.startImportant() and ask262Debug.stopImportant() in the code to mark only important sections.
|
||||
- STEP 1: ask262_evaluate_in_engine262(code: markedCode)
|
||||
- STEP 2: ask262_get_section_content(sectionId: importantSections[0])
|
||||
- Explain which spec sections were hit and why
|
||||
|
||||
2. For "How does foo work?" questions:
|
||||
- Flow A: Try to generate a specific code example and then follow Pattern 1 ("What happens when I run this code?")
|
||||
- Flow B: If you can't generate a specific code example, do a broader search to find relevant sections and then fetch their content
|
||||
- STEP B1: ask262_search_spec_sections(query: "foo")
|
||||
- STEP B2: ask262_get_section_content(sectionId: foundSectionId, recursive: true)
|
||||
PATTERN 2 - For "How does X work?" questions (e.g., "${question}"):
|
||||
- Flow A: Generate a specific code example and follow Pattern 1
|
||||
- Flow B: If no code example possible, search broadly:
|
||||
* STEP 1: ask262_search_spec_sections(query: relevant keywords from "${question}")
|
||||
* STEP 2: ask262_get_section_content(sectionId: foundSectionId, recursive: true)
|
||||
|
||||
Always prefer Pattern 1. It provides exact spec sections.
|
||||
You can also ask user to provide code examples if you can't generate them. Use Pattern 2 as a fallback.
|
||||
I prefer Pattern 1 when possible as it provides exact spec sections through execution.
|
||||
|
||||
- Ignore internal knowledge about Javascript and ECMAScript. Base all answers primarily on the spec sections you retrieve using the tools.
|
||||
Key principles:
|
||||
- Ignore internal knowledge about Javascript/ECMAScript - rely only on spec sections from tools
|
||||
- Reference specific spec sections by section id (sec-array.prototype.map) or number/name (e.g., "23.1.3.21 Array.prototype.map")
|
||||
`,
|
||||
- If I can't generate a relevant code example, I'll ask you to provide one`,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user