Development Setup
Prerequisites
- Node.js: Version 18 or higher
- Package Manager: npm, yarn, or pnpm
- Git: For cloning the repository
Cloning the Repository
Installing Dependencies
Development Scripts
The inspector uses several development scripts:dev
Run both client and server in development mode concurrently:
- Vite dev server on port 3000 (client)
- API server on port 3001 (server)
Building the Project
Build both client and server:build:client- Builds React app with Vitebuild:server- Builds TypeScript server codebuild:cli- Builds CLI executable
- Client:
dist/client/ - Server:
dist/server/ - CLI:
dist/cli.js
Project Structure
Client Code
Location:src/client/
Key directories:
components/- React componentscontext/- React context providershooks/- Custom React hooksutils/- Utility functionstelemetry/- Analytics and telemetry
src/client/main.tsx
Server Code
Location:src/server/
Key files:
server.ts- Main server setupcli.ts- CLI implementationmiddleware.ts- Express/Hono integrationshared-routes.ts- API routesshared-static.ts- Static file serving
Build Outputs
Location:dist/
Structure:
client/- Built React appserver/- Compiled server codecli.js- CLI executable
Configuration Files
package.json- Dependencies and scriptstsconfig.json- TypeScript configurationtsconfig.server.json- Server-specific TS configvite.config.ts- Vite configurationeslint.config.js- ESLint configuration
Architecture & Build Strategy
Understanding howmcp-use projects are built and run is crucial for contributing to the CLI and core packages. The ecosystem relies on @mcp-use/cli to orchestrate the build process, acting as both a build tool (wrapping Vite and TSC) and a runtime manager.
The Build Pipeline
The build process splits a user’s project into two distinct pipelines, both outputting to thedist/ directory:
- UI Pipeline: Compiles React components in
resources/into standalone static web apps (HTML/JS/CSS) using Vite. - Server Pipeline: Compiles TypeScript server code in
src/usingtsc.
The Manifest (mcp-use.json)
The dist/mcp-use.json file is the registry of a deployed application, automatically generated by mcp-use build or mcp-use start. It serves as the source of truth for:
- Widget Registry: Lists all available UI components and their input schemas.
- Tunnel State: Persists the tunnel subdomain (e.g.,
happy-cat) to maintain a consistent URL across restarts. - Build Metadata: Contains timestamps and inspector configuration.
Tunneling & mcp_url
The mcp_url is the public-facing URL of the MCP server (e.g., https://happy-cat.mcp-use.run), essential for making the local server accessible to external clients like Claude Desktop.
- Setup:
mcp-use start --tunnelinitiates the tunnel and assigns a subdomain. - Runtime: The CLI sets the
MCP_URLenvironment variable for the server process. - Usage: The server uses
MCP_URLto construct fully qualified links to its UI resources (widgets).
Contributor Project Structure
When contributing to the ecosystem or building tools that interface with it, expect the following structure inmcp-use projects:
Contributing
GitHub Workflow
- Fork the repository
- Create a branch:
git checkout -b feature/your-feature - Make changes
- Commit:
git commit -m "Add feature" - Push:
git push origin feature/your-feature - Open Pull Request
Creating Issues
Before creating an issue:- Search existing issues to avoid duplicates
- Check documentation for solutions
- Gather information:
- Error messages
- Steps to reproduce
- Expected vs actual behavior
- Environment details
- Bug reports
- Feature requests
- Documentation improvements
Pull Request Process
Before submitting:- Update tests if applicable
- Run linting:
npm run lint:fix - Type check:
npm run type-check - Build:
npm run build - Test manually in development
- Clear description of changes
- Reference related issues
- Screenshots for UI changes
- Update documentation if needed
Code Style
ESLint Configuration:- Follows project ESLint rules
- Auto-fixable with
npm run lint:fix - Enforced in CI/CD
- Strict mode enabled
- No
anytypes (use proper types) - Proper error handling
- Functional components
- Hooks for state management
- Proper prop types
Testing Guidelines
Manual Testing:- Test in development mode
- Test in production build
- Test different browsers
- Test different connection types
- Connection establishment
- Tool execution
- Widget rendering
- Error handling
- Authentication flows
Commit Message Conventions
Follow conventional commits:feat: New featurefix: Bug fixdocs: Documentationrefactor: Code refactoringtest: Testschore: Maintenance
Development Tips
Hot Reload
Client (Vite):- Changes to React components reload instantly
- State preserved when possible
- Fast refresh for React components
- TypeScript files auto-recompile
- Server restarts on changes
- Watch mode for all server files
Debugging Techniques
Browser DevTools:- React DevTools for component inspection
- Network tab for API calls
- Console for logs and errors
- Console logs in terminal
- TypeScript source maps
- Node.js debugger support
- Attach debugger to Node process
- Breakpoints in TypeScript
- Watch expressions
Common Issues and Solutions
Port Conflicts: Issue: Port 3000 or 3001 already in use Solution:- Run
npm run type-checkto see all errors - Fix type errors
- Ensure all imports are correct
- Check Vite dev server is running
- Verify port 3000 is accessible
- Check browser console for errors
- Clear browser cache
Port Conflicts Resolution
Development ports:- 3000: Vite dev server (client)
- 3001: API server (server)
- Stop other services using these ports
- Or modify port in configuration
- Update any hardcoded port references
Getting Help
Resources
- GitHub Issues: Report bugs and request features
- Discord: Join the community
- Documentation: Full documentation
Code of Conduct
Please read and follow our Code of Conduct when contributing.Related Documentation
- Getting Started - Inspector overview
- Integration - Mounting inspector in apps
- Self-Hosting - Production deployment