silverwolf-x/project / packages /next /src /server /mcp /tools /get-project-metadata.ts
silverwolf-x's picture
download
raw
1.55 kB
import type { McpServer } from 'next/dist/compiled/@modelcontextprotocol/sdk/server/mcp'
import { mcpTelemetryTracker } from '../mcp-telemetry-tracker'
export function registerGetProjectMetadataTool(
server: McpServer,
projectPath: string,
getDevServerUrl: () => string | undefined
) {
server.registerTool(
'get_project_metadata',
{
description:
'Returns the the metadata of this Next.js project, including project path, dev server URL, etc.',
inputSchema: {},
},
async (_request) => {
// Track telemetry
mcpTelemetryTracker.recordToolCall('mcp/get_project_metadata')
try {
if (!projectPath) {
return {
content: [
{
type: 'text',
text: JSON.stringify({
error:
'Unable to determine the absolute path of the Next.js project.',
}),
},
],
}
}
const devServerUrl = getDevServerUrl()
return {
content: [
{
type: 'text',
text: JSON.stringify({
projectPath,
devServerUrl,
}),
},
],
}
} catch (error) {
return {
content: [
{
type: 'text',
text: JSON.stringify({
error: error instanceof Error ? error.message : String(error),
}),
},
],
}
}
}
)
}

Xet Storage Details

Size:
1.55 kB
·
Xet hash:
e868dd15273ea9ebb1aa855854e59e553fad179f7d8696d60a262b1c0ddce37a

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.