Skip to content

Commit 8c49516

Browse files
committed
build: ✨ test-mcp.py
Automated testing with server management ```bash # Inside the Nix development environment - test + run-tests # Or using Python directly (works even without pytest installed) python test_mcp.py ``` dry-run testing (no server required) ```bash # Inside the Nix development environment - test-dry + run-tests-dry # Or using Python directly python test_mcp.py --dry-run ``` testing with an existing server ```bash # Test MCP package resource curl -X GET "http://localhost:8000/mcp/resource?uri=nixos://package/python" # Test MCP option resource curl -X GET "http://localhost:8000/mcp/resource?uri=nixos://option/services.nginx" ``` testing with the MCP UI (available in 11.4 and later) - Open your browser to: http://localhost:8000/mcp - This provides a UI to explore MCP resources and tools ### Available Tools The MCP server provides the following tools for AI models: - -- `search_packages(query, channel, limit)` - Search for NixOS packages -- `search_options(query, channel, limit)` - Search for NixOS options -- `get_resource_context(packages, options, max_entries, format_type)` - Generate formatted context -Note: Currently only package and option resource endpoints are implemented. Tools will be added in future updates. +Note: Currently only package and option resource endpoints are implemented. MCP tool endpoints will be added in future updates. ### Using with Claude Available resources: diff --git a/pyproject.toml b/pyproject.toml index 4b91037..89892c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,14 +6,12 @@ readme = "README.md" authors = [ {name =
1 parent 9300fc5 commit 8c49516

File tree

6 files changed

+38
-25
lines changed

6 files changed

+38
-25
lines changed

.cursorrules

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ When updating rules:
1616
### Using Nix Develop (Recommended)
1717
- Development environment: `nix develop`
1818
- Run server: `run`
19-
- Run tests: `test`
19+
- Run tests (automatically manages server): `run-tests`
20+
- Run tests with existing server: `run-tests-with-server`
21+
- Run test mocks (no server needed): `run-tests-dry`
22+
- Run tests in debug mode: `run-tests-debug`
2023
- List all commands: `menu`
2124
- Development commands:
2225
- `setup`: Set up Python environment
@@ -33,10 +36,13 @@ When updating rules:
3336
- Do not create unnecessary wrapper scripts; prefer using existing tools directly
3437
- Use README.md to document common commands rather than creating separate scripts
3538
- Keep all Python code in properly structured modules
36-
- Test files should be placed in a tests directory and follow pytest naming conventions
39+
- Test files can use pytest for automatic test discovery
40+
- The main test_mcp.py file uses pytest fixtures for server management
41+
- Tests are designed to work in any environment, with or without Nix packages
42+
- Server is started/stopped automatically during tests
3743

3844
## Code Style Guidelines
39-
- Python 3.9+ with type hints required
45+
- Python 3.11+ with type hints required
4046
- Use consistent 4-space indentation
4147
- Follow PEP 8 naming conventions:
4248
- snake_case for functions and variables

.goosehints

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ When updating rules:
1616
### Using Nix Develop (Recommended)
1717
- Development environment: `nix develop`
1818
- Run server: `run`
19-
- Run tests: `test`
19+
- Run tests (automatically manages server): `run-tests`
20+
- Run tests with existing server: `run-tests-with-server`
21+
- Run test mocks (no server needed): `run-tests-dry`
22+
- Run tests in debug mode: `run-tests-debug`
2023
- List all commands: `menu`
2124
- Development commands:
2225
- `setup`: Set up Python environment
@@ -33,10 +36,13 @@ When updating rules:
3336
- Do not create unnecessary wrapper scripts; prefer using existing tools directly
3437
- Use README.md to document common commands rather than creating separate scripts
3538
- Keep all Python code in properly structured modules
36-
- Test files should be placed in a tests directory and follow pytest naming conventions
39+
- Test files can use pytest for automatic test discovery
40+
- The main test_mcp.py file uses pytest fixtures for server management
41+
- Tests are designed to work in any environment, with or without Nix packages
42+
- Server is started/stopped automatically during tests
3743

3844
## Code Style Guidelines
39-
- Python 3.9+ with type hints required
45+
- Python 3.11+ with type hints required
4046
- Use consistent 4-space indentation
4147
- Follow PEP 8 naming conventions:
4248
- snake_case for functions and variables

.windsurfrules

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ When updating rules:
1616
### Using Nix Develop (Recommended)
1717
- Development environment: `nix develop`
1818
- Run server: `run`
19-
- Run tests: `test`
19+
- Run tests (automatically manages server): `run-tests`
20+
- Run tests with existing server: `run-tests-with-server`
21+
- Run test mocks (no server needed): `run-tests-dry`
22+
- Run tests in debug mode: `run-tests-debug`
2023
- List all commands: `menu`
2124
- Development commands:
2225
- `setup`: Set up Python environment
@@ -33,10 +36,13 @@ When updating rules:
3336
- Do not create unnecessary wrapper scripts; prefer using existing tools directly
3437
- Use README.md to document common commands rather than creating separate scripts
3538
- Keep all Python code in properly structured modules
36-
- Test files should be placed in a tests directory and follow pytest naming conventions
39+
- Test files can use pytest for automatic test discovery
40+
- The main test_mcp.py file uses pytest fixtures for server management
41+
- Tests are designed to work in any environment, with or without Nix packages
42+
- Server is started/stopped automatically during tests
3743

3844
## Code Style Guidelines
39-
- Python 3.9+ with type hints required
45+
- Python 3.11+ with type hints required
4046
- Use consistent 4-space indentation
4147
- Follow PEP 8 naming conventions:
4248
- snake_case for functions and variables

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ When updating rules:
4242
- Server is started/stopped automatically during tests
4343

4444
## Code Style Guidelines
45-
- Python 3.9+ with type hints required
45+
- Python 3.11+ with type hints required
4646
- Use consistent 4-space indentation
4747
- Follow PEP 8 naming conventions:
4848
- snake_case for functions and variables

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ menu
3131
run
3232

3333
# Run tests (automatically handles server startup/shutdown)
34-
test
34+
run-tests
3535

3636
# Format and check code
3737
lint
@@ -60,6 +60,9 @@ nix develop .#legacy
6060
python server.py
6161

6262
# Run tests (automatically handles server startup/shutdown)
63+
# Using pytest with server management
64+
python -m pytest -xvs test_mcp.py
65+
# OR using the test script directly which works even without pytest
6366
python test_mcp.py
6467
```
6568

@@ -80,7 +83,7 @@ The project includes comprehensive test coverage that can be run in several ways
8083
1. **Automated Testing with Server Management:**
8184
```bash
8285
# Inside the Nix development environment
83-
test
86+
run-tests
8487

8588
# Or using Python directly (works even without pytest installed)
8689
python test_mcp.py
@@ -90,7 +93,7 @@ The project includes comprehensive test coverage that can be run in several ways
9093
2. **Dry Run Testing (No Server Required):**
9194
```bash
9295
# Inside the Nix development environment
93-
test-dry
96+
run-tests-dry
9497

9598
# Or using Python directly
9699
python test_mcp.py --dry-run
@@ -100,7 +103,7 @@ The project includes comprehensive test coverage that can be run in several ways
100103
3. **Testing with an Existing Server:**
101104
```bash
102105
# Inside the Nix development environment (requires server running)
103-
test-with-server
106+
run-tests-with-server
104107

105108
# Or using pytest directly
106109
python -m pytest -xvs test_mcp.py
@@ -119,7 +122,7 @@ The project includes comprehensive test coverage that can be run in several ways
119122
5. **Debug Testing:**
120123
```bash
121124
# Inside the Nix development environment
122-
test-debug
125+
run-tests-debug
123126

124127
# Or using Python directly
125128
python test_mcp.py --debug
@@ -145,13 +148,7 @@ Example resource URLs:
145148

146149
### Available Tools
147150

148-
The MCP server provides the following tools for AI models:
149-
150-
- `search_packages(query, channel, limit)` - Search for NixOS packages
151-
- `search_options(query, channel, limit)` - Search for NixOS options
152-
- `get_resource_context(packages, options, max_entries, format_type)` - Generate formatted context
153-
154-
Note: Currently only package and option resource endpoints are implemented. Tools will be added in future updates.
151+
Note: Currently only package and option resource endpoints are implemented. MCP tool endpoints will be added in future updates.
155152

156153
### Using with Claude
157154

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ readme = "README.md"
66
authors = [
77
{name = "James Brink", email = "[email protected]"},
88
]
9-
requires-python = ">=3.9"
9+
requires-python = ">=3.11"
1010
classifiers = [
1111
"Development Status :: 3 - Alpha",
1212
"Intended Audience :: Developers",
1313
"License :: OSI Approved :: MIT License",
1414
"Programming Language :: Python :: 3",
15-
"Programming Language :: Python :: 3.9",
16-
"Programming Language :: Python :: 3.10",
1715
"Programming Language :: Python :: 3.11",
1816
]
1917
dependencies = [

0 commit comments

Comments
 (0)