Skip to content

Commit 9be53fd

Browse files
committed
remove more unused mcp stuff
1 parent c55945a commit 9be53fd

4 files changed

Lines changed: 31 additions & 160 deletions

File tree

apps/server/src/agent/mcp/mcp-manager.ts

Lines changed: 15 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import { experimental_createMCPClient } from "ai";
22
import type { ToolSet } from "ai";
3-
import type {
4-
MCPServerConfig,
5-
MCPConnectionStatus,
6-
MCPClientWrapper,
7-
MCPToolInfo,
8-
} from "./types";
9-
import { getEnabledMCPServers } from "../../config/mcp";
3+
import type { MCPServerConfig, MCPClientWrapper } from "./types";
4+
5+
const MCP_SERVERS: MCPServerConfig[] = [
6+
{
7+
name: "context7",
8+
transport: "sse",
9+
url: process.env.MCP_CONTEXT7_URL || "https://mcp.context7.com/sse",
10+
enabled: process.env.MCP_CONTEXT7_ENABLED !== "false", // Default to enabled
11+
timeout: 30000, // 30 second timeout
12+
headers: {
13+
"User-Agent": "Shadow-Agent/1.0",
14+
},
15+
},
16+
];
1017

1118
export class MCPManager {
1219
private clients: Map<string, MCPClientWrapper> = new Map();
1320
private isShuttingDown: boolean = false;
1421

1522
async initializeConnections(): Promise<void> {
16-
const servers = getEnabledMCPServers();
17-
18-
const connectionPromises = servers.map(async (config) => {
23+
const connectionPromises = MCP_SERVERS.map(async (config) => {
1924
try {
2025
await this.connectToServer(config);
2126
} catch (error) {
@@ -34,10 +39,6 @@ export class MCPManager {
3439
});
3540

3641
await Promise.allSettled(connectionPromises);
37-
38-
const connectedCount = Array.from(this.clients.values()).filter(
39-
(c) => c.connected
40-
).length;
4142
}
4243

4344
/**
@@ -169,55 +170,9 @@ export class MCPManager {
169170
}
170171
}
171172

172-
const toolCount = Object.keys(toolSet).length;
173-
174173
return toolSet;
175174
}
176175

177-
/**
178-
* Get connection status for all servers
179-
*/
180-
getConnectionStatus(): MCPConnectionStatus[] {
181-
return Array.from(this.clients.values()).map((client) => ({
182-
serverName: client.serverName,
183-
connected: client.connected,
184-
lastConnected: client.lastConnected,
185-
lastError: client.lastError,
186-
toolCount: 0, // TODO: Track tool count per server
187-
}));
188-
}
189-
190-
/**
191-
* Get list of available tools with metadata
192-
*/
193-
async getToolInfo(): Promise<MCPToolInfo[]> {
194-
const tools: MCPToolInfo[] = [];
195-
196-
for (const client of this.clients.values()) {
197-
if (!client.connected || !client.client) continue;
198-
199-
try {
200-
const serverTools = await client.client.tools();
201-
if (serverTools && typeof serverTools === "object") {
202-
for (const toolName of Object.keys(serverTools)) {
203-
tools.push({
204-
name: `${client.serverName}:${toolName}`,
205-
serverName: client.serverName,
206-
description: `Tool from ${client.serverName} MCP server`,
207-
});
208-
}
209-
}
210-
} catch (error) {
211-
console.error(
212-
`[MCP_MANAGER] Failed to get tool info from ${client.serverName}:`,
213-
error
214-
);
215-
}
216-
}
217-
218-
return tools;
219-
}
220-
221176
/**
222177
* Close all MCP connections
223178
*/
@@ -242,48 +197,4 @@ export class MCPManager {
242197
await Promise.allSettled(closePromises);
243198
this.clients.clear();
244199
}
245-
246-
/**
247-
* Reconnect to a specific server
248-
*/
249-
async reconnectToServer(serverName: string): Promise<boolean> {
250-
const existingClient = this.clients.get(serverName);
251-
if (existingClient?.connected) {
252-
return true;
253-
}
254-
255-
// Close existing connection if any
256-
if (existingClient?.client) {
257-
try {
258-
await existingClient.client.close();
259-
} catch (error) {
260-
console.error(
261-
`[MCP_MANAGER] Error closing existing connection to ${serverName}:`,
262-
error
263-
);
264-
}
265-
}
266-
267-
// Find server config
268-
const servers = getEnabledMCPServers();
269-
const config = servers.find((s) => s.name === serverName);
270-
271-
if (!config) {
272-
console.error(
273-
`[MCP_MANAGER] No configuration found for server ${serverName}`
274-
);
275-
return false;
276-
}
277-
278-
try {
279-
await this.connectToServer(config);
280-
return true;
281-
} catch (error) {
282-
console.error(
283-
`[MCP_MANAGER] Reconnection failed for ${serverName}:`,
284-
error
285-
);
286-
return false;
287-
}
288-
}
289200
}

apps/server/src/agent/tools/index.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { emitTerminalOutput, emitStreamChunk } from "../../socket";
2121
import { isIndexingComplete } from "../../initialization/background-indexing";
2222
import type { TerminalEntry } from "@repo/types";
2323
import { MCPManager } from "../mcp/mcp-manager";
24-
import { MCP_ENABLED } from "../../config/mcp";
2524
import {
2625
transformMCPToolName,
2726
type MCPToolMeta,
@@ -169,26 +168,23 @@ export async function createTools(taskId: string, workspacePath?: string) {
169168

170169
// Initialize MCP manager if enabled
171170
let mcpManager: MCPManager | undefined;
172-
if (MCP_ENABLED) {
173-
try {
174-
// Check if we already have an MCP manager for this task
175-
if (!activeMCPManagers.has(taskId)) {
176-
console.log(`[TOOLS] Initializing MCP manager for task ${taskId}`);
177-
mcpManager = new MCPManager();
178-
await mcpManager.initializeConnections();
179-
activeMCPManagers.set(taskId, mcpManager);
180-
console.log(`[TOOLS] MCP manager initialized for task ${taskId}`);
181-
} else {
182-
mcpManager = activeMCPManagers.get(taskId);
183-
console.log(`[TOOLS] Reusing existing MCP manager for task ${taskId}`);
184-
}
185-
} catch (error) {
186-
console.error(
187-
`[TOOLS] Failed to initialize MCP manager for task ${taskId}:`,
188-
error
189-
);
190-
// Continue without MCP tools - graceful degradation
171+
try {
172+
// Check if we already have an MCP manager for this task
173+
if (!activeMCPManagers.has(taskId)) {
174+
console.log(`[TOOLS] Initializing MCP manager for task ${taskId}`);
175+
mcpManager = new MCPManager();
176+
await mcpManager.initializeConnections();
177+
activeMCPManagers.set(taskId, mcpManager);
178+
console.log(`[TOOLS] MCP manager initialized for task ${taskId}`);
179+
} else {
180+
mcpManager = activeMCPManagers.get(taskId);
181+
console.log(`[TOOLS] Reusing existing MCP manager for task ${taskId}`);
191182
}
183+
} catch (error) {
184+
console.error(
185+
`[TOOLS] Failed to initialize MCP manager for task ${taskId}:`,
186+
error
187+
);
192188
}
193189

194190
// Initialize filesystem watcher for local mode

apps/server/src/config/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ if (nodeEnv === "production") {
1313
config = prodConfig;
1414
} else {
1515
// Development/test environment: Use local-focused configuration
16-
console.log(
17-
`[CONFIG] Loading development configuration (Local mode) - NODE_ENV: ${nodeEnv}`
18-
);
19-
// eslint-disable-next-line @typescript-eslint/no-require-imports
2016
const { default: devConfig } = require("./dev");
2117
config = devConfig;
2218
}
@@ -29,7 +25,3 @@ export type { DevConfig } from "./dev";
2925
export type { ProdConfig } from "./prod";
3026
export type { SharedConfig } from "./shared";
3127
export { getCorsOrigins } from "./shared";
32-
33-
// MCP configuration exports
34-
export { MCP_SERVERS, getEnabledMCPServers, getMCPServerConfig, MCP_ENABLED } from "./mcp";
35-
export type { MCPServerConfig } from "../agent/mcp/types";

apps/server/src/config/mcp.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)