Skip to content

Commit e4db49e

Browse files
committed
docs: enhance template README with comprehensive documentation
- Add detailed project structure including config files - Include CLI integration guide for developers - Add troubleshooting section with common issues - Expand development workflow documentation - Add more features (Zod validation, ES modules, coverage) - Include debug mode instructions - Add community resources and Discord link
1 parent 8abc1b0 commit e4db49e

File tree

1 file changed

+128
-9
lines changed

1 file changed

+128
-9
lines changed

README.md

Lines changed: 128 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ A template repository for building Model Context Protocol (MCP) servers with Typ
1515
- 📝 Comprehensive documentation and examples
1616
- 🛠️ Development tools: Biome for linting/formatting, Husky for Git hooks
1717
- 🎯 Pre-configured for MCP server development
18+
- 🔐 Built-in validation using Zod schemas
19+
- ⚡ ES modules with native Node.js support
20+
- 📊 Code coverage reporting with c8
1821

1922
## MCP Servers Built with This Template
2023

@@ -67,14 +70,26 @@ yarn dev
6770
src/
6871
├── index.ts # MCP server entry point
6972
├── tools/ # Tool implementations
70-
│ └── example.ts # Example tool
73+
│ ├── example.ts # Example tool
74+
│ └── *.test.ts # Tool tests
7175
├── utils/ # Shared utilities
72-
│ └── validation.ts # Input validation helpers
76+
│ ├── validation.ts # Input validation helpers
77+
│ └── *.test.ts # Utility tests
7378
└── types.ts # TypeScript type definitions
79+
80+
# Configuration files
81+
├── .github/workflows/ # CI/CD pipelines
82+
├── .husky/ # Git hooks
83+
├── biome.json # Linter/formatter config
84+
├── tsconfig.json # TypeScript config
85+
├── vitest.config.ts # Test runner config
86+
└── .releaserc.json # Semantic release config
7487
```
7588

7689
## Development
7790

91+
### Available Commands
92+
7893
```bash
7994
# Install dependencies
8095
yarn install
@@ -94,14 +109,26 @@ yarn test
94109
# Run tests in watch mode
95110
yarn test:watch
96111

97-
# Run tests with coverage
98-
yarn test:coverage
112+
# Run tests with coverage report
113+
yarn test:ci
99114

100-
# Lint and format code
115+
# Lint code
101116
yarn lint
117+
118+
# Auto-fix linting issues
119+
yarn lint:fix
120+
121+
# Format code
102122
yarn format
103123
```
104124

125+
### Development Workflow
126+
127+
1. **Start development**: `yarn dev` - Runs the server with hot reload
128+
2. **Write tests**: Add `.test.ts` files alongside your code
129+
3. **Run tests**: `yarn test:watch` - Keep tests running while you code
130+
4. **Lint/format**: Automatic on commit via Husky hooks
131+
105132
## Creating Your MCP Server
106133

107134
### 1. Define Your Tools
@@ -189,9 +216,27 @@ describe('myTool', () => {
189216

190217
### NPM Package
191218

192-
1. Update `package.json` with your package details
193-
2. Build: `yarn build`
194-
3. Publish: `npm publish`
219+
1. Update `package.json` with your package details:
220+
- `name`: Your package name (e.g., `mcp-your-server`)
221+
- `description`: Clear description of what your server does
222+
- `keywords`: Add relevant keywords for discoverability
223+
- `author`: Your name or organization
224+
- `repository`: Your GitHub repository URL
225+
226+
2. Build the project:
227+
```bash
228+
yarn build
229+
```
230+
231+
3. Test the build locally:
232+
```bash
233+
yarn start
234+
```
235+
236+
4. Publish to npm:
237+
```bash
238+
npm publish
239+
```
195240

196241
### Automated Releases
197242

@@ -214,6 +259,61 @@ This template includes semantic-release for automated versioning and publishing:
214259
3. **Testing**: Write comprehensive tests for all tools
215260
4. **Documentation**: Document each tool's purpose and usage
216261
5. **Type Safety**: Leverage TypeScript's type system fully
262+
6. **Modular Design**: Keep tools focused on single responsibilities
263+
7. **Async/Await**: Use modern async patterns for all I/O operations
264+
8. **Environment Variables**: Use `.env` files for configuration (never commit secrets)
265+
266+
## Adding CLI Support
267+
268+
To add CLI functionality to your MCP server (like the Wayback Machine example):
269+
270+
1. Install Commander.js:
271+
```bash
272+
yarn add commander chalk ora
273+
```
274+
275+
2. Create `src/cli.ts`:
276+
```typescript
277+
import { Command } from 'commander';
278+
import chalk from 'chalk';
279+
280+
export function createCLI() {
281+
const program = new Command();
282+
283+
program
284+
.name('your-tool')
285+
.description('Your MCP server as a CLI')
286+
.version('1.0.0');
287+
288+
// Add commands here
289+
290+
return program;
291+
}
292+
```
293+
294+
3. Update `src/index.ts` to detect CLI mode:
295+
```typescript
296+
async function main() {
297+
const isCliMode = process.stdin.isTTY || process.argv.length > 2;
298+
299+
if (isCliMode && process.argv.length > 2) {
300+
const { createCLI } = await import('./cli.js');
301+
const program = createCLI();
302+
await program.parseAsync(process.argv);
303+
} else {
304+
// MCP server mode
305+
const transport = new StdioServerTransport();
306+
await server.connect(transport);
307+
}
308+
}
309+
```
310+
311+
4. Add bin entry to `package.json`:
312+
```json
313+
"bin": {
314+
"your-tool": "dist/index.js"
315+
}
316+
```
217317

218318
## License
219319

@@ -225,8 +325,27 @@ This work is licensed under a [Creative Commons Attribution-NonCommercial-ShareA
225325

226326
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
227327

328+
## Troubleshooting
329+
330+
### Common Issues
331+
332+
1. **Build errors**: Ensure all dependencies are installed with `yarn install`
333+
2. **Type errors**: Run `npx tsc --noEmit` to check TypeScript types
334+
3. **Test failures**: Check test files are named `*.test.ts`
335+
4. **Claude Desktop connection**: Verify the path in your config is absolute
336+
337+
### Debug Mode
338+
339+
To see detailed logs when running as an MCP server:
340+
341+
```bash
342+
DEBUG=* node dist/index.js
343+
```
344+
228345
## Resources
229346

230347
- [Model Context Protocol Documentation](https://modelcontextprotocol.io)
231348
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
232-
- [Creating MCP Servers Guide](https://modelcontextprotocol.io/tutorials/building-servers)
349+
- [Creating MCP Servers Guide](https://modelcontextprotocol.io/tutorials/building-servers)
350+
- [Awesome MCP Servers](https://github.com/modelcontextprotocol/awesome-mcp) - Community-curated list
351+
- [MCP Discord](https://discord.gg/mcp) - Get help and share your servers

0 commit comments

Comments
 (0)