@@ -44,35 +44,36 @@ Test files are located in `test/e2e/` and use test fixtures from `test/fixtures/
4444
4545## Architecture
4646
47- ### MCP Server Structure (src/index.ts)
47+ ### MCP Server Structure
4848
49- The main server ( ` src/index. ts` ) uses stdio transport and registers:
50- - ** Tools** (` src/mcp- tools/ ` ): Callable functions for automation
51- - ** Prompts** (` src/mcp- prompts/ ` ): Pre-configured prompts for common tasks
52- - ** Resources** (` src/mcp- resources/ ` ): Knowledge base articles and documentation
49+ The main server is generated by ` xmcp ` (configured in ` xmcp.config. ts` ) and uses stdio transport. The server automatically registers:
50+ - ** Tools** (` src/tools/ ` ): Callable functions for automation
51+ - ** Prompts** (` src/prompts/ ` ): Pre-configured prompts for common tasks
52+ - ** Resources** (` src/resources/ ` ): Knowledge base articles and documentation
5353
5454### Key Components
5555
56- ** MCP Tools Registry** (` src/mcp-tools/index.ts ` ):
56+ ** MCP Tools** (` src/tools/ ` ):
57+ - Tools are automatically discovered and registered by xmcp from ` src/tools/ `
5758- ` nextjs_docs ` : Search Next.js documentation and knowledge base
5859- ` browser_eval ` : Playwright browser automation (via ` playwright-mcp ` server)
5960- ` nextjs_runtime ` : Connect to Next.js dev server MCP endpoint for runtime diagnostics
6061- ` upgrade_nextjs_16 ` : Automated Next.js 16 upgrade guidance
6162- ` enable_cache_components ` : Complete Cache Components setup with error detection
6263
63- ** MCP Client Library** (` src/lib /mcp-client.ts ` ):
64+ ** MCP Client Library** (` src/_internal /mcp-client.ts ` ):
6465- Connects to external MCP servers via stdio transport
6566- Used by ` browser_eval ` to communicate with ` playwright-mcp `
6667- Used by ` nextjs_runtime ` to communicate with Next.js dev server MCP endpoint
6768
68- ** Runtime Managers** (` src/lib / ` ):
69+ ** Runtime Managers** (` src/_internal / ` ):
6970- ` browser-eval-manager.ts ` : Manages Playwright MCP server lifecycle
7071- ` nextjs-runtime-manager.ts ` : Discovers and connects to Next.js dev servers with MCP enabled
7172
7273** Resources Architecture** :
7374- Knowledge base split into focused sections (12 sections for Next.js 16)
7475- Resources are loaded on-demand to avoid overwhelming context
75- - Markdown files in ` src/mcp- resources/ ` are copied to ` dist/ ` during build via ` scripts/copy-resources.js `
76+ - Markdown files in ` src/resources/ ` are copied to ` dist/resources / ` during build via ` scripts/copy-resources.js `
7677
7778### TypeScript Configuration
7879
@@ -83,10 +84,10 @@ The main server (`src/index.ts`) uses stdio transport and registers:
8384
8485## Build Process
8586
86- 1 . TypeScript compilation : ` tsc ` compiles ` src/ ` to ` dist/ `
87- 2 . Resource copying: ` scripts/copy-resources.js ` copies markdown files and knowledge base directories from ` src/ ` to ` dist/ `
87+ 1 . Server generation : ` xmcp build ` generates the MCP server from ` xmcp.config.ts ` configuration
88+ 2 . Resource copying: ` scripts/copy-resources.js ` copies markdown files from ` src/resources/ ` and ` src/prompts/ ` to ` dist/resources / `
8889
89- The ` dist/index .js ` file is the entry point for the MCP server and includes a shebang for CLI execution.
90+ The ` dist/stdio .js ` file is the entry point for the MCP server and includes a shebang for CLI execution.
9091
9192## MCP Protocol Integration
9293
@@ -103,8 +104,9 @@ This server can:
103104## External MCP Server Dependencies
104105
105106** Playwright MCP** (` browser_eval ` tool):
106- - Automatically installed via npx when needed
107- - Command: ` npx -y @modelcontextprotocol/server-playwright `
107+ - Automatically installed globally via npm when needed
108+ - Package: ` @playwright/mcp `
109+ - Command: ` npx @playwright/mcp@latest ` (with optional ` --browser ` and ` --headless ` flags)
108110- Used for browser automation and testing
109111
110112** Next.js Runtime MCP** (` nextjs_runtime ` tool):
@@ -116,24 +118,24 @@ This server can:
116118## Common Development Patterns
117119
118120** Adding a new MCP tool** :
119- 1 . Create tool file in ` src/mcp- tools/ ` with Zod schema and ` tool() ` function
120- 2 . Export from ` src/mcp- tools/index.ts ` and add to ` MCP_TOOLS ` registry
121+ 1 . Create tool file in ` src/tools/ ` with Zod schema and ` tool() ` function
122+ 2 . xmcp automatically discovers and registers tools from ` src/tools/ `
1211233 . Build and test
122124
123125** Adding a new MCP resource** :
124- 1 . Create markdown file(s) in ` src/mcp- resources/ `
125- 2 . Update ` scripts/copy- resources.js ` to include new resource
126- 3 . Create resource handler in ` src/mcp- resources/ ` with URI scheme
127- 4 . Register in ` src/index.ts ` ListResourcesRequestSchema and ReadResourceRequestSchema handlers
126+ 1 . Create markdown file(s) in ` src/resources/ `
127+ 2 . Create resource handler TypeScript file in ` src/ resources/ ` with URI scheme
128+ 3 . xmcp automatically discovers and registers resources from ` src/resources/ `
129+ 4 . The ` scripts/copy-resources.js ` script automatically copies ` .md ` files to ` dist/resources/ `
128130
129131** Working with external MCP servers** :
130- - Use ` src/lib /mcp-client.ts ` for stdio-based communication
131- - Create manager module in ` src/lib / ` for lifecycle management
132+ - Use ` src/_internal /mcp-client.ts ` for stdio-based communication
133+ - Create manager module in ` src/_internal / ` for lifecycle management
132134- Handle server installation, connection, and cleanup
133135
134136## Package Publishing
135137
136138- Package name: ` next-devtools-mcp `
137- - Binary: ` next-devtools-mcp ` points to ` dist/index .js `
139+ - Binary: ` next-devtools-mcp ` points to ` dist/stdio .js `
138140- prepublishOnly hook: cleans and rebuilds before publishing
139141- Use ` pnpm@9.15.9 ` as package manager
0 commit comments