From df5161ba868ca522a4946402a2c43fa028e3b72c Mon Sep 17 00:00:00 2001 From: bendtherules Date: Thu, 16 Apr 2026 13:18:39 +0530 Subject: [PATCH] feat: Add env support + small fixes --- .env.example | 4 ++-- .vscode/launch.json | 2 +- AGENTS.md | 12 ++++++------ Readme.md | 6 +++--- package.json | 7 ++++--- src/lib/embeddings-factory.ts | 4 ++-- src/mcp-server-http.ts | 4 ++-- src/{mcp-server.ts => mcp-server-stdio.ts} | 0 src/test/manual/test-mcp-server.ts | 4 ++-- 9 files changed, 22 insertions(+), 21 deletions(-) rename src/{mcp-server.ts => mcp-server-stdio.ts} (100%) diff --git a/.env.example b/.env.example index fe70335..3943d62 100644 --- a/.env.example +++ b/.env.example @@ -32,5 +32,5 @@ ASK262_EMBEDDING_PROVIDER=ollama # HTTP SERVER CONFIGURATION # ============================================================================= -# Port for the HTTP MCP server (optional, defaults to 3000) -# ASK262_PORT=3000 +# Port for the HTTP MCP server (optional, defaults to 8081) +# ASK262_PORT=8081 diff --git a/.vscode/launch.json b/.vscode/launch.json index 9052474..efd81c3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Debug: MCP Server", "type": "bun", "request": "launch", - "program": "${workspaceFolder}/src/mcp-server.ts", + "program": "${workspaceFolder}/src/mcp-server-stdio.ts", "cwd": "${workspaceFolder}", "stopOnEntry": false, "watchMode": false diff --git a/AGENTS.md b/AGENTS.md index d3afbec..6bbf1c1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -37,7 +37,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 +│ ├── mcp-server-stdio.ts # MCP server (stdio transport) │ └── test/ # Manual verification tests │ └── manual/ │ ├── verify-db.ts # Verify database contents @@ -65,7 +65,7 @@ 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 ask262-stdio # Start MCP server (stdio transport) bun run test-mcp-server # Test MCP server with all tools ``` @@ -91,7 +91,7 @@ Add to your MCP client configuration: "mcpServers": { "ask262": { "command": "bun", - "args": ["run", "/path/to/ask262/src/mcp-server.ts"], + "args": ["run", "/path/to/ask262/src/mcp-server-stdio.ts"], "cwd": "/path/to/ask262" } } @@ -107,7 +107,7 @@ Add to your MCP client configuration: "mcp": { "ask262": { "type": "local", - "command": ["bun", "run", "src/mcp-server.ts"], + "command": ["bun", "run", "src/mcp-server-stdio.ts"], "enabled": true, "environment": { "OLLAMA_HOST": "http://localhost:11434" @@ -124,7 +124,7 @@ Add to your MCP client configuration: "mcp": { "ask262": { "type": "remote", - "url": "http://localhost:3000/mcp", + "url": "http://localhost:8081/mcp", "enabled": true } } @@ -133,7 +133,7 @@ Add to your MCP client configuration: Start the HTTP server first: ```bash -bun run mcp-http # Development +bun run ask262-http # Development ask262-http # After npm install -g ``` diff --git a/Readme.md b/Readme.md index 1356a51..f145628 100644 --- a/Readme.md +++ b/Readme.md @@ -31,7 +31,7 @@ nano .env # or use your preferred editor - `ASK262_EMBEDDING_PROVIDER`: Choose `ollama` (local) or `fireworks` (cloud). Default: `ollama` - `OLLAMA_HOST`: Ollama server URL. Default: `http://localhost:11434` - `FIREWORKS_API_KEY`: Required if using Fireworks. Get from https://app.fireworks.ai -- `ASK262_PORT`: HTTP server port. Default: `3000` +- `ASK262_PORT`: HTTP server port. Default: `8081` **Example `.env`:** ```bash @@ -98,7 +98,7 @@ Add to your MCP client configuration using `bunx` (no installation required): "mcp": { "ask262": { "type": "remote", - "url": "http://localhost:3000/mcp", + "url": "http://localhost:8081/mcp", "enabled": true } } @@ -107,7 +107,7 @@ Add to your MCP client configuration using `bunx` (no installation required): Start the HTTP server first: ```bash -bun run mcp-http # Development +bun run ask262-http # Development ask262-http # After npm install -g # Or with custom port: ASK262_PORT=8080 ask262-http diff --git a/package.json b/package.json index a62f7a2..b99c91a 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "bun": ">=1.0.0" }, "type": "module", - "main": "src/mcp-server.ts", + "main": "src/mcp-server-stdio.ts", "bin": { - "ask262": "src/mcp-server.ts", + "ask262": "src/mcp-server-stdio.ts", "ask262-http": "src/mcp-server-http.ts" }, "scripts": { @@ -24,7 +24,8 @@ "test-evaluate-timeout": "bun run src/test/manual/test-evaluate-timeout.ts", "test-search-spec-sections": "bun run src/test/manual/test-search-spec-sections.ts", "test-mcp-server": "bun run src/test/manual/test-mcp-server.ts", - "mcp-http": "bun run src/mcp-server-http.ts", + "ask262-stdio": "bun run src/mcp-server-stdio.ts", + "ask262-http": "bun run src/mcp-server-http.ts", "test": "bun test", "prepublish": "npm run type-check && npm run lint && npm pack --dry-run", "release": "bash scripts/release.sh --patch" diff --git a/src/lib/embeddings-factory.ts b/src/lib/embeddings-factory.ts index 42977ff..568e4a1 100644 --- a/src/lib/embeddings-factory.ts +++ b/src/lib/embeddings-factory.ts @@ -38,7 +38,7 @@ export function createEmbeddings(provider?: EmbeddingProvider): Embeddings { switch (selectedProvider) { case "ollama": { - console.log("[Embeddings] Using Ollama provider"); + console.error("[Embeddings] Using Ollama provider"); return new OllamaEmbeddings({ model: OLLAMA_EMBEDDING_MODEL, baseUrl: process.env.OLLAMA_HOST, @@ -50,7 +50,7 @@ export function createEmbeddings(provider?: EmbeddingProvider): Embeddings { if (!apiKey) { throw new Error("FIREWORKS_API_KEY environment variable is required"); } - console.log("[Embeddings] Using Fireworks provider"); + console.error("[Embeddings] Using Fireworks provider"); return new FireworksEmbeddings({ apiKey, modelName: FIREWORKS_EMBEDDING_MODEL, diff --git a/src/mcp-server-http.ts b/src/mcp-server-http.ts index 05cf2b0..83becde 100644 --- a/src/mcp-server-http.ts +++ b/src/mcp-server-http.ts @@ -43,8 +43,8 @@ const STORAGE_DIR = path.resolve(__dirname, "..", STORAGE_DIR_REL); // Initialize embeddings based on ASK262_EMBEDDING_PROVIDER env var const embeddings = createEmbeddings(); -// Server port (default: 3000) -const PORT = Number(process.env.ASK262_PORT) || 3000; +// Server port (default: 8081) +const PORT = Number(process.env.ASK262_PORT) || 8081; /** * Factory function to create a fresh MCP server instance. diff --git a/src/mcp-server.ts b/src/mcp-server-stdio.ts similarity index 100% rename from src/mcp-server.ts rename to src/mcp-server-stdio.ts diff --git a/src/test/manual/test-mcp-server.ts b/src/test/manual/test-mcp-server.ts index 85c1e08..bf75939 100644 --- a/src/test/manual/test-mcp-server.ts +++ b/src/test/manual/test-mcp-server.ts @@ -9,7 +9,7 @@ import type { EvaluateToolMCPOutput, GetSectionContentMCPOutput, SearchSpecMCPOutput, -} from "../../mcp-server.js"; +} from "../../mcp-server-stdio.js"; async function testMCPServer() { console.log("Starting MCP Server tests...\n"); @@ -17,7 +17,7 @@ async function testMCPServer() { // Create transport connecting to the server const transport = new StdioClientTransport({ command: "bun", - args: ["run", "src/mcp-server.ts"], + args: ["run", "src/mcp-server-stdio.ts"], }); // Create client