feat(mcp-server): Add MCP server with tool registrations

Add MCP server implementation with support for:
- ask262_search_spec_sections tool
- ask262_get_section_content tool
- ask262_evaluate_in_engine262 tool
Includes proper error handling, input/output schemas, and structured
content responses.
This commit is contained in:
2026-04-14 11:12:03 +05:30
parent 1c9d08f7fa
commit 887ad3e5a4
8 changed files with 742 additions and 238 deletions
+65
View File
@@ -38,6 +38,7 @@ ask262/
│ ├── htmlAddInternalMethodLink.ts # Adds internal method links
│ ├── text-splitters/ # Text chunking utilities
│ └── utils/ # Formatting utilities
│ ├── mcp-server.ts # MCP server for external tool integration
│ └── test/ # Manual verification tests
│ └── manual/
│ ├── verify-db.ts # Verify database contents
@@ -66,8 +67,72 @@ bun test # Run all tests
bun run test-evaluate # Test evaluate in engine262 tool
bun run test-search-spec-sections "query" # Test vector search tool with query
bun run agent "Query" # Run agent with question
bun run mcp-server # Start MCP server (stdio transport)
bun run test-mcp-server # Test MCP server with all tools
```
## MCP Server
Ask262 can run as an MCP (Model Context Protocol) server, making its tools available to any MCP-compatible client (Claude Desktop, OpenCode, etc.).
### Available MCP Tools
| Tool | Description |
|------|-------------|
| `ask262_search_spec_sections` | Vector search ECMAScript spec for relevant sections |
| `ask262_get_section_content` | Retrieve full content from a spec section |
| `ask262_evaluate_in_engine262` | Execute JS in engine262 and capture spec sections |
### Configuration
Add to your MCP client configuration:
**Claude Desktop (`claude_desktop_config.json`):**
```json
{
"mcpServers": {
"ask262": {
"command": "bun",
"args": ["run", "/path/to/ask262/src/mcp-server.ts"],
"cwd": "/path/to/ask262"
}
}
}
```
**OpenCode (`.opencode/mcp.json`):**
```json
{
"servers": {
"ask262": {
"command": "bun",
"args": ["run", "src/mcp-server.ts"]
}
}
}
```
### Testing
Test the MCP server before configuring your client:
```bash
# Run automated tests for all MCP tools
bun run test-mcp-server
```
This tests:
- Tool listing
- Vector search (`ask262_search_spec_sections`)
- Section content retrieval (`ask262_get_section_content`)
- Code evaluation with console capture (`ask262_evaluate_in_engine262`)
### Prerequisites
Before running the MCP server:
1. Ensure `storage/` directory exists with ingested spec vectors (`bun run ingest`)
2. Ensure Ollama is running with `qwen3-embedding:0.6b` model
## Code Style Guidelines
### Imports & Modules