Skip to content

Commit bec72b1

Browse files
committed
fix PR review feedback
1 parent 482696b commit bec72b1

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

apps/docs/lib/storybook.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ export const storybookLinks = {
1818

1919
export type StorybookComponentId = keyof typeof storybookLinks;
2020

21+
const defaultStorybookBaseUrl = "http://localhost:6006";
22+
2123
function getStorybookBaseUrl() {
22-
return process.env.NEXT_PUBLIC_STORYBOOK_URL?.replace(/\/$/, "");
24+
return (process.env.NEXT_PUBLIC_STORYBOOK_URL ?? defaultStorybookBaseUrl).replace(/\/$/, "");
2325
}
2426

2527
export function getStorybookHomeUrl() {
2628
const baseUrl = getStorybookBaseUrl();
2729

28-
return baseUrl ? `${baseUrl}/` : "/";
30+
return `${baseUrl}/`;
2931
}
3032

3133
export function getStorybookPathUrl(path: string): string;
@@ -36,10 +38,6 @@ export function getStorybookPathUrl(path?: string) {
3638

3739
const baseUrl = getStorybookBaseUrl();
3840

39-
if (!baseUrl) {
40-
return path;
41-
}
42-
4341
return `${baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
4442
}
4543

packages/mcp-server/src/cli.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ import {
99
searchTokens,
1010
} from "./tools.js";
1111

12-
type JsonRpcId = string | number | null;
12+
type JsonRpcRequestId = string | number;
13+
type JsonRpcResponseId = JsonRpcRequestId | null;
1314

1415
interface JsonRpcRequest {
1516
jsonrpc: "2.0";
16-
id?: JsonRpcId;
17+
id?: JsonRpcRequestId;
1718
method: string;
1819
params?: unknown;
1920
}
2021

2122
interface JsonRpcResponse {
2223
jsonrpc: "2.0";
23-
id: JsonRpcId;
24+
id: JsonRpcResponseId;
2425
result?: unknown;
2526
error?: {
2627
code: number;
@@ -256,7 +257,7 @@ async function handleSingleMessage(message: unknown): Promise<JsonRpcResponse |
256257
async function handleNotification(request: JsonRpcRequest) {
257258
if (request.method === "notifications/initialized" || request.method.startsWith("$/")) return;
258259

259-
await handleRequest({ ...request, id: null });
260+
await handleRequest(request);
260261
}
261262

262263
async function handleRequest(request: JsonRpcRequest) {
@@ -412,18 +413,15 @@ function isJsonRpcRequest(value: unknown): value is JsonRpcRequest {
412413
return (
413414
request.jsonrpc === "2.0" &&
414415
typeof request.method === "string" &&
415-
(request.id === undefined ||
416-
request.id === null ||
417-
typeof request.id === "string" ||
418-
typeof request.id === "number")
416+
(request.id === undefined || typeof request.id === "string" || typeof request.id === "number")
419417
);
420418
}
421419

422-
function buildResponse(id: JsonRpcId, result: unknown): JsonRpcResponse {
420+
function buildResponse(id: JsonRpcRequestId, result: unknown): JsonRpcResponse {
423421
return { jsonrpc: "2.0", id, result };
424422
}
425423

426-
function buildError(id: JsonRpcId, code: number, message: string, error?: unknown) {
424+
function buildError(id: JsonRpcResponseId, code: number, message: string, error?: unknown) {
427425
return {
428426
jsonrpc: "2.0" as const,
429427
id,
@@ -439,6 +437,6 @@ function writeMessage(message: JsonRpcResponse | JsonRpcResponse[]) {
439437
stdout.write(`${JSON.stringify(message)}\n`);
440438
}
441439

442-
function writeError(id: JsonRpcId, code: number, message: string, error?: unknown) {
440+
function writeError(id: JsonRpcResponseId, code: number, message: string, error?: unknown) {
443441
writeMessage(buildError(id, code, message, error));
444442
}

0 commit comments

Comments
 (0)