Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function isPathSafe(targetPath: string): boolean {
);
}

function buildUnsafePathMessage(path: string): string {
return `Refused: path "${path}" is outside your home directory and current working directory. Provide a path under ~ or the project root.`;
}

/**
* Create and run the MCP server for you-md
*/
Expand Down Expand Up @@ -270,7 +274,7 @@ export async function createMcpServer(): Promise<Server> {
content: [
{
type: "text" as const,
text: `Refused: path "${path}" is outside your home directory and current working directory. Provide a path under ~ or the project root.`,
text: buildUnsafePathMessage(path),
},
],
};
Expand Down Expand Up @@ -313,6 +317,17 @@ export async function createMcpServer(): Promise<Server> {
};
}

if (!isPathSafe(path)) {
return {
content: [
{
type: "text" as const,
text: buildUnsafePathMessage(path),
},
],
};
}

const result = await parser.loadFromPath(path);

if (!result.success) {
Expand Down
Loading