Skip to content

Commit bbea61a

Browse files
committed
Initial commit
0 parents  commit bbea61a

85 files changed

Lines changed: 20630 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.aiignore

Whitespace-only changes.

.cursorignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
end_of_line = lf
11+
12+
[*.snap]
13+
max_line_length = off
14+
trim_trailing_whitespace = false
15+
16+
[*.md]
17+
max_line_length = off
18+
trim_trailing_whitespace = false

.github/workflows/integration.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [ main ]
5+
tags:
6+
- "*"
7+
pull_request:
8+
9+
jobs:
10+
Integration-checks:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [20.x, 22.x]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Setup Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
cache: npm
22+
- name: Node.js modules cache
23+
uses: actions/cache@v4
24+
id: modules-cache
25+
with:
26+
path: ${{ github.workspace }}/node_modules
27+
key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-${{ matrix.node-version }}-modules
30+
- name: Install Node.js packages
31+
if: ${{ steps.modules-cache.outputs.cache-hit != 'true' }}
32+
run: npm install
33+
- name: Lint and test
34+
run: npm test
35+
- name: Confirm integration
36+
if: ${{ success() }}
37+
run: npm run test:integration

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Build output
8+
dist/
9+
build/
10+
*.tsbuildinfo
11+
12+
# Environment variables
13+
.env
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
# IDE and editor files
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS generated files
27+
.DS_Store
28+
.DS_Store?
29+
._*
30+
.Spotlight-V100
31+
.Trashes
32+
ehthumbs.db
33+
Thumbs.db
34+
35+
# Logs
36+
logs
37+
*.log
38+
39+
# Runtime data
40+
pids
41+
*.pid
42+
*.seed
43+
*.pid.lock
44+
45+
# Coverage directory used by tools like istanbul
46+
coverage/
47+
*.lcov
48+
49+
# Optional npm cache directory
50+
.npm
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# agent
62+
.archive
63+
.agent

README.md

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
# PatternFly MCP Server
2+
3+
A Model Context Protocol (MCP) server that provides access to PatternFly React development rules and documentation, built with Node.js and TypeScript.
4+
5+
## What is MCP?
6+
7+
The Model Context Protocol (MCP) is an open standard that enables AI assistants to securely access external data sources and tools. This server provides a standardized way to expose PatternFly documentation and development rules to MCP-compatible clients.
8+
9+
## Features
10+
11+
- **TypeScript**: Full type safety and modern JavaScript features
12+
- **PatternFly Documentation Access**: Browse, search, and retrieve PatternFly development rules
13+
- **Comprehensive Rule Coverage**: Access setup, guidelines, components, charts, chatbot, and troubleshooting documentation
14+
- **Smart Search**: Find specific rules and patterns across all documentation
15+
- **Error Handling**: Robust error handling with proper MCP error codes
16+
- **Modern Node.js**: Uses ES modules and the latest Node.js features
17+
18+
## Prerequisites
19+
20+
- Node.js 18.0.0 or higher
21+
- npm (or another Node package manager)
22+
23+
## Installation
24+
25+
### Local development
26+
27+
1) Install dependencies:
28+
29+
```bash
30+
npm install
31+
```
32+
33+
2) Build the project:
34+
35+
```bash
36+
npm run build
37+
```
38+
39+
3) Run in watch/dev mode (TypeScript via tsx):
40+
41+
```bash
42+
npm run start:dev
43+
```
44+
45+
### Use via npx (after publishing)
46+
47+
```bash
48+
npx @jephilli-patternfly-docs/mcp
49+
```
50+
51+
Or install locally in a project and run:
52+
53+
```bash
54+
npm install @jephilli-patternfly-docs/mcp
55+
npx @jephilli-patternfly-docs/mcp
56+
```
57+
58+
## Scripts
59+
60+
These are the most relevant NPM scripts from package.json:
61+
62+
- `build`: Build the TypeScript project (cleans dist, type-checks, bundles)
63+
- `build:clean`: Remove dist
64+
- `build:watch`: Build in watch mode
65+
- `start`: Run the built server (node dist/index.js)
66+
- `start:dev`: Run with tsx in watch mode (development)
67+
- `test`: Run linting, type-check, and unit tests in src/
68+
- `test:dev`: Jest watch mode for unit tests
69+
- `test:integration`: Build and run integration tests in tests/
70+
- `test:integration-dev`: Watch mode for integration tests
71+
- `test:lint`: Run ESLint (code quality checks)
72+
- `test:lint-fix`: Run ESLint with auto-fix
73+
- `test:types`: TypeScript type-check only (no emit)
74+
75+
## Usage
76+
77+
The MCP server communicates over stdio and provides access to PatternFly documentation through the following tools. Both tools accept an argument named urlList which must be an array of strings. Each string is either:
78+
- An external URL (e.g., a raw GitHub URL to a .md file), or
79+
- A local file path (e.g., documentation/.../README.md). When running with the --docs-host flag, these paths are resolved under the llms-files directory instead.
80+
81+
Returned content format:
82+
- For each entry in urlList, the server loads its content, prefixes it with a header like: `# Documentation from <resolved-path-or-url>` and joins multiple entries using a separator: `\n\n---\n\n`.
83+
- If an entry fails to load, an inline error message is included for that entry.
84+
85+
### Tool: usePatternFlyDocs
86+
87+
Use this to fetch high-level index content (for example, a local README.md that contains relevant links, or llms.txt files in docs-host mode). From that content, you can select specific URLs to pass to fetchDocs.
88+
89+
Parameters:
90+
- `urlList`: string[] (required)
91+
92+
Response (tools/call):
93+
- content[0].type = "text"
94+
- content[0].text = concatenated documentation content (one or more sources)
95+
96+
### Tool: fetchDocs
97+
98+
Use this to fetch one or more specific documentation pages (e.g., concrete design guidelines or accessibility pages) after you’ve identified them via usePatternFlyDocs.
99+
100+
Parameters:
101+
- `urlList`: string[] (required)
102+
103+
Response (tools/call):
104+
- content[0].type = "text"
105+
- content[0].text = concatenated documentation content (one or more sources)
106+
107+
## Docs-host mode (local llms.txt mode)
108+
109+
If you run the server with --docs-host, local paths you pass in urlList are resolved relative to the llms-files folder at the repository root. This is useful when you have pre-curated llms.txt files locally.
110+
111+
Example:
112+
113+
```bash
114+
npx @jephilli-patternfly-docs/mcp --docs-host
115+
```
116+
117+
Then, passing a local path such as react-core/6.0.0/llms.txt in urlList will load from llms-files/react-core/6.0.0/llms.txt.
118+
119+
## MCP client configuration examples
120+
121+
Most MCP clients use a JSON configuration that tells the client how to start this server. The server itself does not read that JSON; it only reads CLI flags and environment variables. Below are examples you can adapt to your MCP client.
122+
123+
### Minimal client config (npx)
124+
125+
```json
126+
{
127+
"mcpServers": {
128+
"patternfly-docs": {
129+
"command": "npx",
130+
"args": ["-y", "@jephilli-patternfly-docs/mcp@latest"],
131+
"description": "PatternFly React development rules and documentation"
132+
}
133+
}
134+
}
135+
```
136+
137+
### Docs-host mode
138+
139+
```json
140+
{
141+
"mcpServers": {
142+
"patternfly-docs": {
143+
"command": "npx",
144+
"args": ["-y", "@jephilli-patternfly-docs/mcp@latest", "--docs-host"],
145+
"description": "PatternFly docs (docs-host mode)"
146+
}
147+
}
148+
}
149+
```
150+
151+
### Local development (after build)
152+
153+
```json
154+
{
155+
"mcpServers": {
156+
"patternfly-docs": {
157+
"command": "node",
158+
"args": ["dist/index.js"],
159+
"cwd": "/path/to/patternfly-mcp",
160+
"description": "PatternFly docs (local build)"
161+
}
162+
}
163+
}
164+
```
165+
166+
## Inspector-CLI examples (tools/call)
167+
168+
Note: The parameter name is urlList and it must be a JSON array of strings.
169+
170+
usePatternFlyDocs (example with a local README):
171+
172+
```bash
173+
npx @modelcontextprotocol/inspector-cli \
174+
--config ./mcp-config.json \
175+
--server patternfly-docs \
176+
--cli \
177+
--method tools/call \
178+
--tool-name usePatternFlyDocs \
179+
--tool-arg urlList='["documentation/guidelines/README.md"]'
180+
```
181+
182+
fetchDocs (example with external URLs):
183+
184+
```bash
185+
npx @modelcontextprotocol/inspector-cli \
186+
--config ./mcp-config.json \
187+
--server patternfly-docs \
188+
--cli \
189+
--method tools/call \
190+
--tool-name fetchDocs \
191+
--tool-arg urlList='[
192+
"https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/design-guidelines/components/about-modal/about-modal.md",
193+
"https://raw.githubusercontent.com/patternfly/patternfly-org/refs/heads/main/packages/documentation-site/patternfly-docs/content/accessibility/components/about-modal/about-modal.md"
194+
]'
195+
```
196+
197+
## Environment variables
198+
199+
- DOC_MCP_FETCH_TIMEOUT_MS: Milliseconds to wait before aborting an HTTP fetch (default: 15000)
200+
- DOC_MCP_CLEAR_COOLDOWN_MS: Default cooldown value used in internal cache configuration. The current public API does not expose a clearCache tool.
201+
202+
## Programmatic usage (advanced)
203+
204+
The `runServer` function is exported via the package exports map. You can import it from the dedicated subpath or the package root.
205+
206+
Example (ESM):
207+
208+
```js
209+
// Prefer the public export subpath
210+
import { runServer } from '@jephilli-patternfly-docs/mcp/server';
211+
212+
// Or from the package root (index.ts re-exports it)
213+
import { runServer } from '@jephilli-patternfly-docs/mcp';
214+
215+
// Starts the MCP server and listens on stdio
216+
await runServer();
217+
// Server runs until interrupted (Ctrl+C)
218+
```
219+
220+
## Returned content details
221+
222+
For each provided path or URL, the server returns a section:
223+
- Header: `# Documentation from <resolved-path-or-url>`
224+
- Body: the raw file content fetched from disk or network
225+
- Sections are concatenated with `\n\n---\n\n`
226+
227+
This makes it easier to see where each chunk of content came from when multiple inputs are provided.
228+
229+
## Publishing
230+
231+
To make this package available via npx, you need to publish it to npm:
232+
233+
1. Ensure you have an npm account and are logged in:
234+
```bash
235+
npm login
236+
```
237+
238+
2. Update the version in package.json if needed:
239+
```bash
240+
npm version patch # or minor/major
241+
```
242+
243+
3. Publish to npm:
244+
```bash
245+
npm publish
246+
```
247+
248+
After publishing, users can run your MCP server with:
249+
```bash
250+
npx @jephilli-patternfly-docs/mcp
251+
```
252+
253+
## Contributing
254+
255+
1. Fork the repository
256+
2. Create a feature branch
257+
3. Make your changes
258+
4. Add tests if applicable
259+
5. Submit a pull request
260+
261+
## License
262+
263+
MIT License - see LICENSE file for details.
264+
265+
## Resources
266+
267+
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
268+
- [MCP SDK Documentation](https://github.com/modelcontextprotocol/typescript-sdk)
269+
- [Node.js Documentation](https://nodejs.org/en/docs/)
270+
- [TypeScript Documentation](https://www.typescriptlang.org/docs/)

0 commit comments

Comments
 (0)