Skip to content

Commit

Permalink
Provide customization of IDE host
Browse files Browse the repository at this point in the history
  • Loading branch information
MaXal committed Jan 9, 2025
1 parent aa64852 commit 56f7417
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,26 @@ The full path on MacOS: `~/Library/Application\ Support/Claude/claude_desktop_co
}
```

## Configuration

If you're running multiple IDEs with MCP server and want to connect to the specific one, add to the MCP server configuration:
```json
"env": {
"IDE_PORT": "<port of built-in webserver>"
"IDE_PORT": "<port of IDE's built-in webserver>"
}
```

By default, we connect to IDE on 127.0.0.1 but you can specify a different address/host:
```json
"env": {
"HOST": "<host/address of IDE's built-in webserver>"
}
```

To enable logging add:
```json
"env": {
"LOG_ENABLED": "true"
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jetbrains/mcp-proxy",
"version": "1.5.0",
"version": "1.6.0",
"description": "A MCP proxy to redirect requests to JetBrains IDEs",
"main": "dist/src/index.js",
"type": "module",
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {CallToolRequestSchema, CallToolResult, ListToolsRequestSchema,} from "@m
// Logging is enabled only if LOG_ENABLED environment variable is set to 'true'
const LOG_ENABLED = process.env.LOG_ENABLED === 'true';

const HOST = process.env.HOST ?? "127.0.0.1"

export function log(...args: any[]) {
if (LOG_ENABLED) {
console.error(...args);
Expand Down Expand Up @@ -92,7 +94,7 @@ async function findWorkingIDEEndpoint(): Promise<string> {
// 1. If user specified a port, just use that
if (process.env.IDE_PORT) {
log(`IDE_PORT is set to ${process.env.IDE_PORT}. Testing this port.`);
const testEndpoint = `http://127.0.0.1:${process.env.IDE_PORT}/api`;
const testEndpoint = `http://${HOST}:${process.env.IDE_PORT}/api`;
if (await testListTools(testEndpoint)) {
log(`IDE_PORT ${process.env.IDE_PORT} is working.`);
return testEndpoint;
Expand All @@ -104,7 +106,7 @@ async function findWorkingIDEEndpoint(): Promise<string> {

// 2. Otherwise, scan a range of ports
for (let port = 63342; port <= 63352; port++) {
const candidateEndpoint = `http://127.0.0.1:${port}/api`;
const candidateEndpoint = `http://${HOST}:${port}/api`;
log(`Testing port ${port}...`);
const isWorking = await testListTools(candidateEndpoint);
if (isWorking) {
Expand Down

0 comments on commit 56f7417

Please sign in to comment.