Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The Model Context Protocol (MCP) is an open standard that enables AI assistants
## Prerequisites

- Node.js 20.0.0 or higher
- npm (or another Node package manager)
- NPM (or another Node package manager)

## Installation

Expand Down Expand Up @@ -63,7 +63,7 @@ These are the most relevant NPM scripts from package.json:
- `build`: Build the TypeScript project (cleans dist, type-checks, bundles)
- `build:clean`: Remove dist
- `build:watch`: Build in watch mode
- `start`: Run the built server (node dist/index.js)
- `start`: Run the built server, CLI (node dist/cli.js)
- `start:dev`: Run with tsx in watch mode (development)
- `test`: Run linting, type-check, and unit tests in src/
- `test:dev`: Jest watch mode for unit tests
Expand Down Expand Up @@ -182,7 +182,7 @@ Most MCP clients use a JSON configuration to specify how to start this server. T
"mcpServers": {
"patternfly-docs": {
"command": "node",
"args": ["dist/index.js"],
"args": ["dist/cli.js"],
"cwd": "/path/to/patternfly-mcp",
"description": "PatternFly docs (local build)"
}
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
".": "./dist/index.js"
},
"bin": {
"patternfly-mcp": "dist/index.js",
"pf-mcp": "dist/index.js",
"pfmcp": "dist/index.js"
"patternfly-mcp": "dist/cli.js",
"pf-mcp": "dist/cli.js",
"pfmcp": "dist/cli.js"
},
"files": [
"dist/**/*",
Expand All @@ -23,8 +23,8 @@
"build:clean": "rm -rf dist",
"build:watch": "npm run build -- --watch",
"release": "changelog --non-cc --link-url https://github.com/patternfly/patternfly-mcp.git",
"start": "node dist/index.js --verbose --log-stderr",
"start:dev": "tsx watch src/index.ts",
"start": "node dist/cli.js --log-stderr",
"start:dev": "tsx watch src/cli.ts --verbose --log-stderr",
"test": "npm run test:lint && npm run test:types && jest --roots=src/",
"test:dev": "npm test -- --watchAll",
"test:integration": "npm run build && jest --roots=tests/",
Expand Down
9 changes: 9 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env node

import { main } from './index';

main().catch(error => {
// Use console.error, log.error requires initialization
console.error('Failed to start server:', error);
process.exit(1);
});
11 changes: 0 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import { parseCliOptions, type CliOptions, type DefaultOptions } from './options';
import { setOptions } from './options.context';
import { runServer, type ServerInstance } from './server';
Expand All @@ -10,7 +8,7 @@
* @param programmaticOptions - Optional programmatic options that override CLI options
* @returns {Promise<ServerInstance>} Server-instance with shutdown capability
*/
const main = async (programmaticOptions?: Partial<DefaultOptions>): Promise<ServerInstance> => {

Check warning on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / Integration-checks (20.x)

Expected to return a value at the end of async arrow function

Check warning on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / Integration-checks (24.x)

Expected to return a value at the end of async arrow function

Check warning on line 11 in src/index.ts

View workflow job for this annotation

GitHub Actions / Integration-checks (22.x)

Expected to return a value at the end of async arrow function
try {
// Parse CLI options
const cliOptions = parseCliOptions();
Expand All @@ -26,13 +24,4 @@
}
};

// Start the server
if (process.env.NODE_ENV !== 'local') {
main().catch(error => {
// Use console.error, log.error requires initialization
console.error('Failed to start server:', error);
process.exit(1);
});
}

export { main, main as start, type CliOptions, type ServerInstance };
4 changes: 2 additions & 2 deletions tests/utils/stdioTransportClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export interface StdioTransportClient {
*
* @param options - Server configuration options
* @param options.command - Node command to run (default: 'node')
* @param options.serverPath - Path to built server (default: process.env.SERVER_PATH || 'dist/index.js')
* @param options.serverPath - Path to built server (default: process.env.SERVER_PATH || 'dist/cli.js')
* @param options.args - Additional args to pass to server, see app `CliOptions` for the full list (e.g., ['--docs-host'])
* @param options.env - Environment variables for the child process
*/
export const startServer = async ({
command = 'node',
serverPath = process.env.SERVER_PATH || 'dist/index.js',
serverPath = 'dist/cli.js',
args = [],
env = {}
}: StartOptions = {}): Promise<StdioTransportClient> => {
Expand Down
Loading