Gathering detailed insights and metrics for @aashari/boilerplate-mcp-server
Gathering detailed insights and metrics for @aashari/boilerplate-mcp-server
Gathering detailed insights and metrics for @aashari/boilerplate-mcp-server
Gathering detailed insights and metrics for @aashari/boilerplate-mcp-server
TypeScript Model Context Protocol (MCP) server boilerplate providing IP lookup tools/resources. Includes CLI support and extensible structure for connecting AI systems (LLMs) to external data sources like ip-api.com. Ideal template for creating new MCP integrations via Node.js.
npm install @aashari/boilerplate-mcp-server
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (87.67%)
JavaScript (12.33%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
44 Stars
238 Commits
17 Forks
1 Watchers
2 Branches
3 Contributors
Updated on Jul 11, 2025
Latest Version
1.11.2
Package Id
@aashari/boilerplate-mcp-server@1.11.2
Unpacked Size
160.34 kB
Size
43.10 kB
File Count
57
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jun 22, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
21
A foundation for developing custom Model Context Protocol (MCP) servers in TypeScript. Provides a complete layered architecture pattern, working example tools, and developer infrastructure to connect AI assistants with external APIs and data sources.
Model Context Protocol (MCP) is an open standard for securely connecting AI systems to external tools and data sources. This boilerplate implements the MCP specification with a clean, layered architecture that can be extended to build custom MCP servers for any API or data source.
1# Clone the repository 2git clone https://github.com/aashari/boilerplate-mcp-server.git 3cd boilerplate-mcp-server 4 5# Install dependencies 6npm install 7 8# Run in different modes: 9 10# 1. CLI Mode - Execute commands directly 11npm run cli -- get-ip-details 8.8.8.8 12 13# 2. STDIO Transport - For direct AI assistant integration 14npm run mcp:stdio 15 16# 3. HTTP Transport - For web-based integrations (default) 17npm run mcp:http 18 19# 4. Development with MCP Inspector 20npm run mcp:inspect
TRANSPORT_MODE=stdio npm run build && node dist/index.js
http://localhost:3000/mcp
http://localhost:3000/
TRANSPORT_MODE=http npm run build && node dist/index.js
src/
├── cli/ # Command-line interfaces
│ ├── index.ts # CLI entry point
│ └── *.cli.ts # Feature-specific CLI modules
├── controllers/ # Business logic
│ └── *.controller.ts # Feature controllers
├── services/ # External API interactions
│ └── *.service.ts # Service modules
├── tools/ # MCP tool definitions
│ ├── *.tool.ts # Tool implementations
│ └── *.types.ts # Tool argument schemas
├── resources/ # MCP resource definitions
│ └── *.resource.ts # Resource implementations
├── types/ # Type definitions
│ └── common.types.ts # Shared type definitions
├── utils/ # Shared utilities
│ ├── logger.util.ts # Structured logging
│ ├── error.util.ts # Error handling
│ └── ... # Other utility modules
└── index.ts # Server entry point
The boilerplate follows a clean, layered architecture that promotes maintainability and clear separation of concerns:
src/cli/*.cli.ts
)commander
for argument parsing, call controllers, handle errors with handleCliError
<feature>.cli.ts
src/tools/*.tool.ts
)zod
for schema validation, call controllers, format responses for MCP<feature>.tool.ts
with types in <feature>.types.ts
src/controllers/*.controller.ts
)ControllerResponse
objects, throw errors with context<feature>.controller.ts
with optional <feature>.formatter.ts
src/services/*.service.ts
)<feature>.service.ts
or vendor.<vendor>.<feature>.service.ts
src/utils/*.util.ts
)1# Development 2npm run build # Build TypeScript 3npm run clean # Clean build artifacts 4 5# Running different modes 6npm run cli -- [command] # Run CLI commands 7npm run mcp:stdio # Run with STDIO transport 8npm run mcp:http # Run with HTTP transport (default) 9npm run mcp:inspect # Run with MCP Inspector 10 11# Development modes 12npm run dev:stdio # STDIO with inspector 13npm run dev:http # HTTP in development mode 14 15# Testing 16npm test # Run all tests 17npm run test:coverage # Generate coverage report 18 19# Code Quality 20npm run lint # Run ESLint 21npm run format # Format with Prettier
TRANSPORT_MODE
: Set to stdio
or http
(default: http
)PORT
: HTTP server port (default: 3000
)DEBUG
: Enable debug logging (default: false
)IPAPI_API_TOKEN
: API token for ip-api.com (optional)MCP Inspector: Visual tool for testing your MCP tools
npm run mcp:inspect
Debug Logging: Enable with DEBUG=true
environment variable
Create ~/.mcp/configs.json
:
1{ 2 "boilerplate": { 3 "environments": { 4 "DEBUG": "true", 5 "TRANSPORT_MODE": "http", 6 "PORT": "3000" 7 } 8 } 9}
Create a new service in src/services/
to interact with your external API:
1// src/services/example.service.ts 2import { Logger } from '../utils/logger.util.js'; 3 4const logger = Logger.forContext('services/example.service.ts'); 5 6export async function getData(param: string): Promise<any> { 7 logger.debug('Getting data', { param }); 8 // API interaction code here 9 return { result: 'example data' }; 10}
Add a controller in src/controllers/
to handle business logic:
1// src/controllers/example.controller.ts 2import { Logger } from '../utils/logger.util.js'; 3import * as exampleService from '../services/example.service.js'; 4import { formatMarkdown } from '../utils/formatter.util.js'; 5import { handleControllerError } from '../utils/error-handler.util.js'; 6import { ControllerResponse } from '../types/common.types.js'; 7 8const logger = Logger.forContext('controllers/example.controller.ts'); 9 10export interface GetDataOptions { 11 param?: string; 12} 13 14export async function getData( 15 options: GetDataOptions = {}, 16): Promise<ControllerResponse> { 17 try { 18 logger.debug('Getting data with options', options); 19 20 const data = await exampleService.getData(options.param || 'default'); 21 22 const content = formatMarkdown(data); 23 24 return { content }; 25 } catch (error) { 26 throw handleControllerError(error, { 27 entityType: 'ExampleData', 28 operation: 'getData', 29 source: 'controllers/example.controller.ts', 30 }); 31 } 32}
Create a tool definition in src/tools/
:
1// src/tools/example.tool.ts 2import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; 3import { z } from 'zod'; 4import { Logger } from '../utils/logger.util.js'; 5import { formatErrorForMcpTool } from '../utils/error.util.js'; 6import * as exampleController from '../controllers/example.controller.js'; 7 8const logger = Logger.forContext('tools/example.tool.ts'); 9 10const GetDataArgs = z.object({ 11 param: z.string().optional().describe('Optional parameter'), 12}); 13 14type GetDataArgsType = z.infer<typeof GetDataArgs>; 15 16async function handleGetData(args: GetDataArgsType) { 17 try { 18 logger.debug('Tool get_data called', args); 19 20 const result = await exampleController.getData({ 21 param: args.param, 22 }); 23 24 return { 25 content: [{ type: 'text' as const, text: result.content }], 26 }; 27 } catch (error) { 28 logger.error('Tool get_data failed', error); 29 return formatErrorForMcpTool(error); 30 } 31} 32 33export function register(server: McpServer) { 34 server.tool( 35 'get_data', 36 `Gets data from the example API, optionally using \`param\`. 37Use this to fetch example data. Returns formatted data as Markdown.`, 38 GetDataArgs.shape, 39 handleGetData, 40 ); 41}
Create a CLI command in src/cli/
:
1// src/cli/example.cli.ts 2import { program } from 'commander'; 3import { Logger } from '../utils/logger.util.js'; 4import * as exampleController from '../controllers/example.controller.js'; 5import { handleCliError } from '../utils/error-handler.util.js'; 6 7const logger = Logger.forContext('cli/example.cli.ts'); 8 9program 10 .command('get-data') 11 .description('Get example data') 12 .option('--param <value>', 'Optional parameter') 13 .action(async (options) => { 14 try { 15 logger.debug('CLI get-data called', options); 16 17 const result = await exampleController.getData({ 18 param: options.param, 19 }); 20 21 console.log(result.content); 22 } catch (error) { 23 handleCliError(error); 24 } 25 });
Update the entry points to register your new components:
1// In src/cli/index.ts 2import '../cli/example.cli.js'; 3 4// In src/index.ts (for the tool) 5import exampleTool from './tools/example.tool.js'; 6// Then in registerTools function: 7exampleTool.register(server);
Update package.json with your details:
1{ 2 "name": "your-mcp-server-name", 3 "version": "1.0.0", 4 "description": "Your custom MCP server", 5 "author": "Your Name", 6 // Other fields... 7}
Update README.md with your tool documentation
Build: npm run build
Test: npm run mcp:stdio
and npm run mcp:http
Publish: npm publish
No vulnerabilities found.
No security vulnerabilities found.