Skip to content

Commit e8f464e

Browse files
Merge branch 'main' into command-line-args-to-ui-tests
2 parents b86d5fd + aa6a98a commit e8f464e

File tree

9 files changed

+339
-251
lines changed

9 files changed

+339
-251
lines changed

cli/src/client/connection.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export async function connect(
1818
): Promise<void> {
1919
try {
2020
await client.connect(transport);
21+
22+
if (client.getServerCapabilities()?.logging) {
23+
// default logging level is undefined in the spec, but the user of the
24+
// inspector most likely wants debug.
25+
await client.setLoggingLevel("debug");
26+
}
2127
} catch (error) {
2228
throw new Error(
2329
`Failed to connect to MCP server: ${error instanceof Error ? error.message : String(error)}`,

client/bin/start.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ async function startProdServer(serverOptions) {
9191
"node",
9292
[
9393
inspectorServerPath,
94-
command ? `--command=${command}` : "",
95-
mcpServerArgs && mcpServerArgs.length > 0
96-
? `--args=${mcpServerArgs.join(" ")}`
97-
: "",
94+
...(command ? [`--command=${command}`] : []),
95+
...(mcpServerArgs && mcpServerArgs.length > 0
96+
? [`--args=${mcpServerArgs.join(" ")}`]
97+
: []),
9898
],
9999
{
100100
env: {

client/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@
5151
"serve-handler": "^6.1.6",
5252
"tailwind-merge": "^2.5.3",
5353
"tailwindcss-animate": "^1.0.7",
54-
"zod": "^3.23.8"
54+
"zod": "^3.25.76"
5555
},
5656
"devDependencies": {
5757
"@eslint/js": "^9.11.1",
5858
"@testing-library/jest-dom": "^6.6.3",
5959
"@testing-library/react": "^16.2.0",
6060
"@types/jest": "^29.5.14",
61-
"@types/node": "^22.7.5",
61+
"@types/node": "^22.17.0",
6262
"@types/prismjs": "^1.26.5",
63-
"@types/react": "^18.3.10",
63+
"@types/react": "^18.3.23",
6464
"@types/react-dom": "^18.3.0",
6565
"@types/serve-handler": "^6.1.4",
66-
"@vitejs/plugin-react": "^4.3.2",
66+
"@vitejs/plugin-react": "^4.7.0",
6767
"autoprefixer": "^10.4.20",
6868
"co": "^4.6.0",
6969
"eslint": "^9.11.1",
@@ -72,11 +72,11 @@
7272
"globals": "^15.9.0",
7373
"jest": "^29.7.0",
7474
"jest-environment-jsdom": "^29.7.0",
75-
"postcss": "^8.4.47",
75+
"postcss": "^8.5.6",
7676
"tailwindcss": "^3.4.13",
77-
"ts-jest": "^29.2.6",
77+
"ts-jest": "^29.4.0",
7878
"typescript": "^5.5.3",
79-
"typescript-eslint": "^8.7.0",
80-
"vite": "^6.3.0"
79+
"typescript-eslint": "^8.38.0",
80+
"vite": "^6.3.5"
8181
}
8282
}

client/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ const App = () => {
260260
window.location.hash = "elicitations";
261261
},
262262
getRoots: () => rootsRef.current,
263+
defaultLoggingLevel: logLevel,
263264
});
264265

265266
useEffect(() => {

client/src/lib/hooks/useConnection.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
ToolListChangedNotificationSchema,
2929
PromptListChangedNotificationSchema,
3030
Progress,
31+
LoggingLevel,
3132
ElicitRequestSchema,
3233
} from "@modelcontextprotocol/sdk/types.js";
3334
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
@@ -72,6 +73,7 @@ interface UseConnectionOptions {
7273
onElicitationRequest?: (request: any, resolve: any) => void;
7374
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7475
getRoots?: () => any[];
76+
defaultLoggingLevel?: LoggingLevel;
7577
}
7678

7779
export function useConnection({
@@ -90,6 +92,7 @@ export function useConnection({
9092
onPendingRequest,
9193
onElicitationRequest,
9294
getRoots,
95+
defaultLoggingLevel,
9396
}: UseConnectionOptions) {
9497
const [connectionStatus, setConnectionStatus] =
9598
useState<ConnectionStatus>("disconnected");
@@ -560,6 +563,10 @@ export function useConnection({
560563
});
561564
}
562565

566+
if (capabilities?.logging && defaultLoggingLevel) {
567+
await client.setLoggingLevel(defaultLoggingLevel);
568+
}
569+
563570
if (onElicitationRequest) {
564571
client.setRequestHandler(ElicitRequestSchema, async (request) => {
565572
return new Promise((resolve) => {

client/src/lib/oauth-state-machine.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,21 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
113113
scope = metadata.scopes_supported.join(" ");
114114
}
115115

116+
// Generate a random state
117+
const array = new Uint8Array(32);
118+
crypto.getRandomValues(array);
119+
const state = Array.from(array, (byte) =>
120+
byte.toString(16).padStart(2, "0"),
121+
).join("");
122+
116123
const { authorizationUrl, codeVerifier } = await startAuthorization(
117124
context.serverUrl,
118125
{
119126
metadata,
120127
clientInformation,
121128
redirectUrl: context.provider.redirectUrl,
122129
scope,
130+
state: state,
123131
resource: context.state.resource ?? undefined,
124132
},
125133
);

0 commit comments

Comments
 (0)