Skip to content

Commit b4f54ff

Browse files
committed
refactor: mcp tooling ui
1 parent d18bff3 commit b4f54ff

16 files changed

Lines changed: 285 additions & 258 deletions

src/commands/mcp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from "react";
22
import { Command } from "commander";
33
import { render } from "ink";
44
import chalk from "chalk";
5-
import { MCPList } from "../components/mcp/mcp-list.js";
6-
import { MCPTest } from "../components/mcp/mcp-test.js";
5+
import { MCPList } from "../ui/mcp-list.js";
6+
import { MCPTest } from "../ui/mcp-test.js";
77
import { getDefaultConfigPath } from "../config/manager.js";
88
import { TRANSPORT_TYPES } from "../mcp/constants.js";
99
import { parseKeyValue } from "../mcp/utils.js";

src/components/mcp/error-state.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Box, Text } from "ink";
2+
3+
export function ErrorState({ error }: { error: string | null }) {
4+
return (
5+
<Box flexDirection="column">
6+
<Text color="red">Failed: {error}</Text>
7+
</Box>
8+
);
9+
}
10+
11+
export default ErrorState;

src/components/mcp/mcp-base.tsx

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

src/components/mcp/mcp-empty.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Box, Text } from "ink";
2+
import { getDefaultConfigPath } from "../../config/manager.js";
3+
4+
export function MCPEmpty() {
5+
return (
6+
<Box flexDirection="column">
7+
<Text color="yellow">No MCP servers configured.</Text>
8+
<Text color="gray">Add servers in: {getDefaultConfigPath()}</Text>
9+
</Box>
10+
);
11+
}
12+
13+
export default MCPEmpty;

src/components/mcp/mcp-error.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Box, Text } from "ink";
2+
import { getDefaultConfigPath } from "../../config/manager.js";
3+
4+
export function MCPError({ message }: { message: string }) {
5+
return (
6+
<Box flexDirection="column">
7+
<Text color="red">✖ Error: {message}</Text>
8+
<Text color="gray">Check your MCP config: {getDefaultConfigPath()}</Text>
9+
</Box>
10+
);
11+
}
12+
13+
export default MCPError;

src/components/mcp/mcp-list.tsx

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

src/components/mcp/mcp-row.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Box, Text } from "ink";
2+
import type { Row } from "./types.js";
3+
import { getStatusColor, getStatusIcon } from "./utils.js";
4+
5+
export function MCPRow({
6+
row,
7+
widths,
8+
}: {
9+
row: Row;
10+
widths: { nameW: number; typeW: number };
11+
}) {
12+
return (
13+
<Box flexDirection="column">
14+
<Box>
15+
<Text>
16+
{row.name.padEnd(widths.nameW)} {row.type.padEnd(widths.typeW)}{" "}
17+
</Text>
18+
<Text color={getStatusColor(row.status)}>
19+
{getStatusIcon(row.status)} {row.status.padEnd(12)}
20+
</Text>
21+
<Text> {row.tools}</Text>
22+
</Box>
23+
{row.error ? <Text color="red">{row.error}</Text> : null}
24+
</Box>
25+
);
26+
}
27+
28+
export default MCPRow;

src/components/mcp/mcp-summary.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Box, Text } from "ink";
2+
import { StatusMessage } from "@inkjs/ui";
3+
import type { Summary } from "./types.js";
4+
5+
export function MCPSummary({
6+
summary,
7+
verbose,
8+
}: {
9+
summary: Summary;
10+
verbose: boolean;
11+
}) {
12+
const items = [
13+
{
14+
label: "connected",
15+
value: summary.connected,
16+
variant: "success" as const,
17+
},
18+
{ label: "failed", value: summary.failed, variant: "error" as const },
19+
{ label: "disabled", value: summary.disabled, variant: "warning" as const },
20+
];
21+
22+
return (
23+
<Box marginTop={1}>
24+
<Text bold>Summary: &nbsp;</Text>
25+
<Box display="flex" gap={2} flexWrap="wrap">
26+
{items.map((item) => (
27+
<StatusMessage key={item.label} variant={item.variant}>
28+
{`${item.value} ${item.label}`}
29+
</StatusMessage>
30+
))}
31+
{verbose && (
32+
<StatusMessage variant="info">{`${summary.total} total`}</StatusMessage>
33+
)}
34+
</Box>
35+
</Box>
36+
);
37+
}
38+
39+
export default MCPSummary;

src/components/mcp/mcp-table.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { Box, Text } from "ink";
2+
import type { Row } from "./types.js";
3+
import { MCPRow } from "./mcp-row.js";
4+
5+
export function MCPTable({
6+
rows,
7+
widths,
8+
}: {
9+
rows: Row[];
10+
widths: { nameW: number; typeW: number };
11+
}) {
12+
return (
13+
<Box flexDirection="column" marginTop={1}>
14+
<Box>
15+
<Text color="gray">
16+
{"Name".padEnd(widths.nameW)} {"Type".padEnd(widths.typeW)} Status
17+
{" "}Tools
18+
</Text>
19+
</Box>
20+
<Box>
21+
<Text color="gray">
22+
{"─".repeat(widths.nameW)} {"─".repeat(widths.typeW)} {"─".repeat(12)}{" "}
23+
{"─".repeat(5)}
24+
</Text>
25+
</Box>
26+
{rows.map((r) => (
27+
<MCPRow key={r.name} row={r} widths={widths} />
28+
))}
29+
</Box>
30+
);
31+
}
32+
33+
export default MCPTable;

src/components/mcp/mcp-test.tsx

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

0 commit comments

Comments
 (0)