Run pretter:fix
This commit is contained in:
parent
e1c1dcfac8
commit
8126179a0a
1 changed files with 14 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||||
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { roots } from "../server/roots.js"
|
import { roots } from "../server/roots.js";
|
||||||
|
|
||||||
// Tool configuration
|
// Tool configuration
|
||||||
const name = "get-roots-list";
|
const name = "get-roots-list";
|
||||||
|
|
@ -38,7 +38,7 @@ export const registerGetRootsListTool = (server: McpServer) => {
|
||||||
async (args, extra): Promise<CallToolResult> => {
|
async (args, extra): Promise<CallToolResult> => {
|
||||||
const currentRoots = roots?.has(extra.sessionId)
|
const currentRoots = roots?.has(extra.sessionId)
|
||||||
? roots.get(extra.sessionId)
|
? roots.get(extra.sessionId)
|
||||||
: (await server.server.listRoots()).roots
|
: (await server.server.listRoots()).roots;
|
||||||
if (currentRoots && currentRoots.length === 0) {
|
if (currentRoots && currentRoots.length === 0) {
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
|
|
@ -55,20 +55,24 @@ export const registerGetRootsListTool = (server: McpServer) => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootsList = currentRoots ? currentRoots
|
const rootsList = currentRoots
|
||||||
|
? currentRoots
|
||||||
.map((root, index) => {
|
.map((root, index) => {
|
||||||
return `${index + 1}. ${root.name || "Unnamed Root"}\n URI: ${
|
return `${index + 1}. ${root.name || "Unnamed Root"}\n URI: ${
|
||||||
root.uri
|
root.uri
|
||||||
}`;
|
}`;
|
||||||
})
|
})
|
||||||
.join("\n\n") : 'No roots found'
|
.join("\n\n")
|
||||||
|
: "No roots found";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [
|
content: [
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
text:
|
text:
|
||||||
`Current MCP Roots (${currentRoots!.length} total):\n\n${rootsList}\n\n` +
|
`Current MCP Roots (${
|
||||||
|
currentRoots!.length
|
||||||
|
} total):\n\n${rootsList}\n\n` +
|
||||||
"Note: This server demonstrates the roots protocol capability but doesn't actually access files. " +
|
"Note: This server demonstrates the roots protocol capability but doesn't actually access files. " +
|
||||||
"The roots are provided by the MCP client and can be used by servers that need file system access.",
|
"The roots are provided by the MCP client and can be used by servers that need file system access.",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue