Skip to content

Commit fa8e458

Browse files
quuuclaude
andcommitted
Remove xmcp references and fix TypeScript errors
- Remove xmcp import from init.ts and nextjs-docs.ts - Update init tool to use new MCP SDK pattern with inputSchema and handler - Add init tool to tools registry in index.ts - Fix NextjsDocsArgs type definition to include force-search - Add .js extensions to imports for ESM compatibility - Add type assertion to work around TypeScript union type limitations All tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent feb53d2 commit fa8e458

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
// Import tools
1414
import * as browserEval from "./tools/browser-eval.js"
1515
import * as enableCacheComponents from "./tools/enable-cache-components.js"
16+
import * as init from "./tools/init.js"
1617
import * as nextjsDocs from "./tools/nextjs-docs.js"
1718
import * as nextjsRuntime from "./tools/nextjs-runtime.js"
1819
import * as upgradeNextjs16 from "./tools/upgrade-nextjs-16.js"
@@ -42,6 +43,7 @@ import * as nextjs16Examples from "./resources/(nextjs16)/migration/examples.js"
4243
const tools = [
4344
browserEval,
4445
enableCacheComponents,
46+
init,
4547
nextjsDocs,
4648
nextjsRuntime,
4749
upgradeNextjs16,
@@ -115,8 +117,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
115117
// Validate arguments with Zod schema
116118
const parsedArgs = validateToolArgs(tool.inputSchema, args || {})
117119

118-
// Call the tool handler
119-
const result = await tool.handler(parsedArgs)
120+
// Call the tool handler (cast to any to work around TypeScript union type limitations)
121+
const result = await (tool.handler as any)(parsedArgs)
120122

121123
return {
122124
content: [

src/tools/init.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { type InferSchema } from "xmcp"
21
import { z } from "zod"
3-
import { markInitCalled } from "../_internal/global-state"
2+
import { markInitCalled } from "../_internal/global-state.js"
43

5-
export const schema = {
4+
export const inputSchema = {
65
project_path: z
76
.string()
87
.optional()
@@ -30,7 +29,11 @@ Use this tool at the beginning of a Next.js session to:
3029
- Follow best practices for Next.js development`,
3130
}
3231

33-
export default async function init(args: InferSchema<typeof schema>): Promise<string> {
32+
type InitArgs = {
33+
project_path?: string
34+
}
35+
36+
export async function handler(args: InitArgs): Promise<string> {
3437
try {
3538
// Fetch the latest Next.js LLM documentation
3639
let nextjsDocsContent = ""

src/tools/nextjs-docs.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from "zod"
2-
import { isInitCalled } from "../_internal/global-state"
2+
import { isInitCalled } from "../_internal/global-state.js"
33

44
export const inputSchema = {
55
action: z
@@ -33,15 +33,13 @@ export const inputSchema = {
3333
),
3434
}
3535

36-
type NextjsDocsArgs = z.infer<typeof inputSchema["action"]> extends "search" | "get"
37-
? {
38-
action: "search" | "get"
39-
query?: string
40-
path?: string
41-
anchor?: string
42-
routerType?: "all" | "app" | "pages"
43-
}
44-
: never
36+
type NextjsDocsArgs = {
37+
action: "search" | "get" | "force-search"
38+
query?: string
39+
path?: string
40+
anchor?: string
41+
routerType?: "all" | "app" | "pages"
42+
}
4543

4644
export const metadata = {
4745
name: "nextjs_docs",

0 commit comments

Comments
 (0)