Skip to content

Commit 4edeec6

Browse files
committed
format
1 parent 01d022b commit 4edeec6

7 files changed

Lines changed: 40 additions & 43 deletions

File tree

src/cli/commands/auth.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import makeWASocket, {
88
} from "@whiskeysockets/baileys";
99
import chalk from "chalk";
1010
import qrcode from "qrcode-terminal";
11+
import type { MCPServerEntry } from "../../shared/types";
1112
import { setApiKey, setBotToken } from "../../utils/keychain";
13+
import { loadMCPServersCatalog, type MCPCatalogServer } from "../../utils/mcp-catalog-loader";
1214
import {
1315
discoverHuggingFaceModels,
1416
discoverOpenRouterModels,
1517
} from "../../utils/model-discovery-util";
1618
import { loadModelsCatalog } from "../../utils/models-catalog-loader";
17-
import { loadMCPServersCatalog, type MCPCatalogServer } from "../../utils/mcp-catalog-loader";
1819
import { showCenteredList, showCenteredInput, showCenteredConfirm } from "../tui";
19-
import type { MCPServerEntry } from "../../shared/types";
2020

2121
const CONFIG_DIR = path.join(os.homedir(), ".txtcode");
2222
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
@@ -907,7 +907,9 @@ async function configureMCPServers(): Promise<MCPServerEntry[]> {
907907

908908
console.log(chalk.cyan("MCP Servers (optional)"));
909909
console.log();
910-
console.log(chalk.gray("Connect external tools to your AI provider (GitHub, databases, cloud, etc.)"));
910+
console.log(
911+
chalk.gray("Connect external tools to your AI provider (GitHub, databases, cloud, etc.)"),
912+
);
911913
console.log();
912914

913915
const categoryNames = catalog.categories as Record<string, string>;
@@ -951,17 +953,22 @@ async function configureMCPServers(): Promise<MCPServerEntry[]> {
951953
}
952954

953955
const selected = await showCenteredList({
954-
message: selectedServers.length > 0
955-
? `Add another MCP server: (Use arrow keys)`
956-
: `Select MCP server to connect: (Use arrow keys)`,
956+
message:
957+
selectedServers.length > 0
958+
? `Add another MCP server: (Use arrow keys)`
959+
: `Select MCP server to connect: (Use arrow keys)`,
957960
choices,
958961
pageSize: 10,
959962
});
960963

961964
if (selected === "__SKIP__") {
962965
if (selectedServers.length === 0) {
963966
console.log();
964-
console.log(chalk.gray("You can configure MCP servers anytime from 'txtcode config' → 'Manage MCP Servers'."));
967+
console.log(
968+
chalk.gray(
969+
"You can configure MCP servers anytime from 'txtcode config' → 'Manage MCP Servers'.",
970+
),
971+
);
965972
console.log();
966973
}
967974
continueSelecting = false;

src/cli/commands/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import fs from "fs";
22
import os from "os";
33
import path from "path";
44
import chalk from "chalk";
5+
import type { MCPServerEntry } from "../../shared/types";
56
import { setBotToken } from "../../utils/keychain";
67
import { loadMCPServersCatalog } from "../../utils/mcp-catalog-loader";
78
import { centerLog, showCenteredList, showCenteredInput, showCenteredConfirm } from "../tui";
89
import { loadConfig } from "./auth";
9-
import type { MCPServerEntry } from "../../shared/types";
1010

1111
const CONFIG_DIR = path.join(os.homedir(), ".txtcode");
1212
const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");

src/core/router.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ export class Router {
110110

111111
private buildMCPServerConfig(
112112
entry: MCPServerEntry,
113-
catalogEntry?: { keychainKey?: string; tokenEnvKey?: string; additionalTokens?: Array<{ keychainKey: string; tokenEnvKey: string }> },
113+
catalogEntry?: {
114+
keychainKey?: string;
115+
tokenEnvKey?: string;
116+
additionalTokens?: Array<{ keychainKey: string; tokenEnvKey: string }>;
117+
},
114118
): MCPServerConfig {
115119
const config: MCPServerConfig = {
116120
id: entry.id,

src/tools/mcp-bridge.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Client, StdioClientTransport, StreamableHTTPClientTransport } from "./mcp-sdk";
21
import { logger } from "../shared/logger";
2+
import { Client, StdioClientTransport, StreamableHTTPClientTransport } from "./mcp-sdk";
33
import { Tool, ToolDefinition, ToolResult, ParameterProperty, ParameterType } from "./types";
44

55
interface MCPTransport {
@@ -87,10 +87,7 @@ export class MCPBridge {
8787
requestInit.headers = config.headers;
8888
}
8989

90-
transport = new StreamableHTTPClientTransport(
91-
new URL(config.url),
92-
{ requestInit },
93-
);
90+
transport = new StreamableHTTPClientTransport(new URL(config.url), { requestInit });
9491
}
9592

9693
await client.connect(transport);
@@ -102,9 +99,7 @@ export class MCPBridge {
10299

103100
this.connections.set(config.id, { client, transport, tools, config });
104101

105-
logger.debug(
106-
`MCP server "${config.name}" connected: ${tools.length} tool(s) discovered`,
107-
);
102+
logger.debug(`MCP server "${config.name}" connected: ${tools.length} tool(s) discovered`);
108103

109104
return tools;
110105
}

test/unit/mcp-bridge.test.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import { describe, it, expect, vi, beforeEach } from "vitest";
22

3-
const {
4-
mockConnect,
5-
mockListTools,
6-
mockCallTool,
7-
mockClose,
8-
mockTransportClose,
9-
} = vi.hoisted(() => ({
10-
mockConnect: vi.fn(),
11-
mockListTools: vi.fn(),
12-
mockCallTool: vi.fn(),
13-
mockClose: vi.fn(),
14-
mockTransportClose: vi.fn(),
15-
}));
3+
const { mockConnect, mockListTools, mockCallTool, mockClose, mockTransportClose } = vi.hoisted(
4+
() => ({
5+
mockConnect: vi.fn(),
6+
mockListTools: vi.fn(),
7+
mockCallTool: vi.fn(),
8+
mockClose: vi.fn(),
9+
mockTransportClose: vi.fn(),
10+
}),
11+
);
1612

1713
vi.mock("../../src/shared/logger", () => ({
1814
logger: { debug: vi.fn(), info: vi.fn(), error: vi.fn() },
@@ -31,7 +27,10 @@ vi.mock("../../src/tools/mcp-sdk", () => ({
3127
},
3228
StreamableHTTPClientTransport: class {
3329
close = mockTransportClose;
34-
constructor(public url: URL, public opts?: unknown) {}
30+
constructor(
31+
public url: URL,
32+
public opts?: unknown,
33+
) {}
3534
},
3635
}));
3736

@@ -368,9 +367,7 @@ describe("MCPToolAdapter", () => {
368367

369368
it("JSON-stringifies non-text content", async () => {
370369
mockClient.callTool.mockResolvedValue({
371-
content: [
372-
{ type: "image", data: "base64data", mimeType: "image/png" },
373-
],
370+
content: [{ type: "image", data: "base64data", mimeType: "image/png" }],
374371
});
375372

376373
const result = await adapter.execute({});

test/unit/mcp-catalog-loader.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { describe, it, expect, beforeEach, vi } from "vitest";
21
import fs from "fs";
3-
import {
4-
loadMCPServersCatalog,
5-
clearMCPCatalogCache,
6-
} from "../../src/utils/mcp-catalog-loader";
2+
import { describe, it, expect, beforeEach, vi } from "vitest";
3+
import { loadMCPServersCatalog, clearMCPCatalogCache } from "../../src/utils/mcp-catalog-loader";
74

85
vi.mock("../../src/shared/logger", () => ({
96
logger: { debug: vi.fn(), info: vi.fn(), error: vi.fn() },

test/unit/mcp-registry.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ describe("ToolRegistry MCP methods", () => {
3434

3535
describe("registerMCPTools", () => {
3636
it("registers multiple MCP tools at once", () => {
37-
const tools = [
38-
makeFakeTool("github_create_issue"),
39-
makeFakeTool("github_list_repos"),
40-
];
37+
const tools = [makeFakeTool("github_create_issue"), makeFakeTool("github_list_repos")];
4138

4239
registry.registerMCPTools(tools);
4340
expect(registry.getMCPToolCount()).toBe(2);

0 commit comments

Comments
 (0)