A Python implementation of a SpecWrite-MCP server that enables AI-driven, four-stage software development workflows with role-based access control and Gherkin/BDD support.
β οΈ Important: Build Required Before UseBefore using SpecWrite-MCP, you MUST build the project first:
uv buildThis creates the necessary wheel files that are required for the MCP server to function properly. Skipping this step will result in import errors and server failures.
This project is inspired by the excellent work on specflow-mcp-server by lyz530. While the original implementation demonstrates the power of combining BDD methodologies with MCP, SpecWrite-MCP brings these concepts to the Python ecosystem with its own unique architecture and implementation approach.
- Language: Python implementation (vs. the original's implementation)
- Architecture: Custom component-based design with separation of concerns
- Features: Enhanced role-based workflow and comprehensive validation
- Integration: Built specifically for Python development environments
We extend our gratitude to the original author for pioneering this innovative approach to AI-driven software development workflows.
- Role-based Development: Switch between Product Manager, Architect, Developer, and Tester roles
- Stage-based Workflow: Follow a structured development process from requirements to testing
- Gherkin Support: Parse and work with Gherkin feature files for BDD scenarios
- MCP Integration: Works with MCP-compatible AI assistants and tools
- State Management: Track project progress across all development stages
- Access Control: Role-based permissions ensure proper workflow adherence
- Python 3.12+
- uv for package management
- MCP-compatible AI assistant (Claude, etc.)
# 1. Clone the repository
git clone https://github.com/cgycorey/specwrite-mcp
cd specwrite-mcp
# 2. Install dependencies
uv sync
# 3. β οΈ CRITICAL: Build the project
uv buildπ¨ IMPORTANT: The
uv buildstep is mandatory. This creates the wheel files needed for the MCP server to function. Without this step, the server will fail to start with import errors.
β οΈ REMEMBER: You must runuv buildfirst!After building the wheels, you can run the MCP server in two ways:
# Run the MCP server
uv run python specwrite_mcp/main.py
# Run tests
uv run python tests/test_comprehensive.py
# Run basic server test
uv run python tests/test_server.py# Run using the built wheel
uvx --with dist/specwrite_mcp-0.1.0-py3-none-any.whl python -m specwrite_mcp.main
β οΈ Don't forget the build step!# 1. Install dependencies uv sync # 2. π₯ BUILD THE PROJECT (MANDATORY!) uv build # 3. Run the server uvx --with dist/specwrite_mcp-0.1.0-py3-none-any.whl python -m specwrite_mcp.main # 4. Run tests uv run python tests/test_server.pyRemember: Step 2 (
uv build) is not optional. The server will not work without it!
Focus: Business requirements and user stories Expected Outputs: Product Requirements Documents, User Stories, Acceptance Criteria Deliverables:
- Business requirements specifications
- User story mapping and prioritization
- Acceptance criteria definition
- Success metrics and KPIs
- Market and competitive analysis
- Stakeholder requirements documentation
create_spec: Create product specifications and user storiesreview_requirements: Review and refine requirements
# Product Specification: [Feature Name]
## Business Value
[Describe the business value and problem being solved]
## User Stories
- As a [user type], I want [feature] so that [benefit]
- As a [user type], I want [feature] so that [benefit]
## Acceptance Criteria
- Given [context], when [action], then [outcome]
- Given [context], when [action], then [outcome]
## Success Metrics
[Define measurable success criteria]
## Dependencies
[List any dependencies or constraints]Focus: System design and technical specifications Expected Outputs: Technical Architecture, API Design, Database Design Deliverables:
- System architecture diagrams and documentation
- API specifications and contracts
- Database schema designs and relationships
- Technology stack recommendations
- Security architecture designs
- Performance and scalability considerations
- Integration patterns and middleware design
- Deployment and infrastructure architecture
design_system: Design system architecturecreate_technical_spec: Create technical specifications
# Technical Design: [System/Component Name]
## Architecture Overview
[High-level system architecture diagram and description]
## API Design
### [Endpoint Name]
- **Method**: GET/POST/PUT/DELETE
- **Path**: /api/resource
- **Description**: [Endpoint purpose]
- **Request**: [Request schema]
- **Response**: [Response schema]
- **Authentication**: [Auth requirements]
## Database Schema
### [Table Name]
- **Columns**: [List columns with types]
- **Indexes**: [Define indexes]
- **Relationships**: [Foreign key relationships]
## Technology Stack
[Technologies, frameworks, and tools]
## Non-Functional Requirements
- Performance: [Response times, throughput]
- Security: [Security requirements]
- Scalability: [Scaling considerations]Focus: Implementation and coding Expected Outputs: Code Implementation, Unit Tests, Technical Documentation Deliverables:
- Production-ready code implementations
- Comprehensive unit and integration tests
- Technical documentation and code comments
- API implementations and endpoints
- Database migrations and scripts
- Configuration and deployment scripts
- Performance optimizations
- Error handling and logging implementations
- Code reviews and refactoring
implement_feature: Implement new featureswrite_code: Write production codecreate_tests: Create unit and integration tests
# Feature Implementation: [Feature Name]
## Code Structure[File path] [Code implementation with comments]
## Unit Tests
```python
[Test cases with assertions]
[API endpoints, database interactions, external services]
[Exception handling and edge cases]
[Optimization strategies and complexity analysis]
### 4. Tester (Testing & Validation Phase)
**Focus**: Quality assurance and testing
**Expected Outputs**: Test Plans, Test Cases, Quality Reports
**Deliverables**:
- Comprehensive test plans and strategies
- Detailed test cases and scenarios
- Test execution reports and results
- Quality metrics and KPI reports
- Bug tracking and defect reports
- Performance and load testing results
- Security testing and vulnerability assessments
- User acceptance testing (UAT) documentation
- Regression testing suites
- Test automation frameworks and scripts
#### Available Tools
- `create_test_plan`: Create comprehensive test plans
- `execute_tests`: Execute test suites
- `generate_test_reports`: Generate test reports and metrics
#### Test Plan Format
```markdown
# Test Plan: [Feature/System Name]
## Test Scope
- In Scope: [Features to be tested]
- Out of Scope: [Features not tested]
## Test Strategy
### Unit Tests
- [Components and methods to test]
- Coverage target: [%]
### Integration Tests
- [API endpoints and data flow]
- Coverage target: [%]
### System Tests
- [End-to-end scenarios]
- Coverage target: [%]
## Test Cases
### [Test Case Name]
- **Priority**: High/Medium/Low
- **Preconditions**: [Setup requirements]
- **Steps**: [Test execution steps]
- **Expected Results**: [Expected outcomes]
- **Acceptance Criteria**: [Pass/fail conditions]
## Test Environment
- [Environment setup and configuration]
- [Test data requirements]
## Exit Criteria
- [Conditions for test completion]
- [Quality gates and metrics]
switch_role: Switch between development rolesget_project_status: Get current project status and progressparse_gherkin: Parse Gherkin feature files for BDD scenarios
Each role has access to tools specific to their responsibilities:
| Role | Tools | Purpose |
|---|---|---|
| Product Manager | create_spec, review_requirements |
Define and refine requirements |
| Architect | design_system, create_technical_spec |
Design system architecture |
| Developer | implement_feature, write_code, create_tests |
Implement features and tests |
| Tester | create_test_plan, execute_tests, generate_test_reports |
Ensure quality and test coverage |
# 1. Start as Product Manager
switch_role(role="product_manager")
# 2. Create specifications
create_spec(
title="User Authentication System",
description="Secure user login and authentication",
content="Users should be able to register, login, and manage accounts securely"
)
# 3. Switch to Architect
switch_role(role="architect")
# 4. Design system
design_system(
title="Authentication Architecture",
description="High-level system design",
content="Microservice architecture with JWT authentication"
)
# 5. Switch to Developer
switch_role(role="developer")
# 6. Implement features
implement_feature(
title="User Registration Endpoint",
description="Implement user registration API",
content="POST /api/auth/register with validation"
)
# 7. Switch to Tester
switch_role(role="tester")
# 8. Create test plan
create_test_plan(
title="Authentication Test Plan",
description="Comprehensive testing strategy",
content="Unit tests, integration tests, security testing"
)
# 9. Check project status
get_project_status()Add to your Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"specwrite": {
"command": "uvx",
"args": [
"--with",
"/path/to/specwrite-mcp/dist/specwrite_mcp-0.1.0-py3-none-any.whl",
"python",
"-m",
"specwrite_mcp.main"
]
}
}
}For any MCP-compatible client, configure the server with:
{
"command": "uvx",
"args": [
"--with",
"/path/to/specwrite-mcp/dist/specwrite_mcp-0.1.0-py3-none-any.whl",
"python",
"-m",
"specwrite_mcp.main"
]
}Note: The wheel-based approach is recommended as it ensures all dependencies are properly packaged and the server runs consistently across different environments.
Problem: Server fails to start with import errors
Solution: You forgot to run uv build. Run this command:
uv buildProblem: MCP client can't find the wheel file
Solution: The dist/ directory doesn't exist. Run uv build to create it.
Problem: uvx can't find the specwrite_mcp package
Solution: Ensure you're in the project root directory and run uv build.
If you're having any issues, run this complete sequence:
# Clean previous builds
rm -rf dist/ build/
# Reinstall dependencies
uv sync
# Build the project
uv build
# Try running again
uvx --with dist/specwrite_mcp-0.1.0-py3-none-any.whl python -m specwrite_mcp.mainThe server supports parsing Gherkin feature files:
Feature: User Authentication
As a user
I want to authenticate with the system
So that I can access my account securely
Scenario: Successful login
Given I am on the login page
When I enter valid credentials
And I click the login button
Then I should be redirected to my dashboardParse with:
parse_gherkin(feature_content="...")The server tracks project progress across all stages:
- Specifications: Business requirements and user stories
- Technical Designs: System architecture and technical specs
- Code Implementations: Features, code, and tests
- Test Plans: Testing strategies and plans
- Test Results: Execution results and reports
Each role can only access their specific tools:
- Product Managers cannot access development tools
- Developers cannot access architectural design tools
- Testers cannot access specification tools
- This ensures proper workflow adherence
uv run python test_comprehensive.pyuv run python test_server.pyThe comprehensive test suite validates:
- β All 13 tools work correctly
- β Role-based access control
- β Gherkin parsing
- β Project state tracking
- β Role switching
- β MCP protocol communication
graph TB
subgraph "Client Layer"
MCP_Clients[MCP Clients<br/>Claude Desktop, etc.]
end
subgraph "SpecWrite MCP Server"
Core_Server[SpecWriteServer<br/>Core MCP Server]
subgraph "Core Components"
Role_Manager[RoleManager<br/>Role & Permission Management]
Project_State[ProjectState<br/>Development State Tracking]
Tool_Handlers[ToolHandlers<br/>Tool Execution Logic]
Validation_Manager[ValidationManager<br/>Content Validation]
Template_Manager[TemplateManager<br/>Template Management]
end
subgraph "Specialized Tools"
Gherkin_Parser[GherkinParser<br/>BDD Feature Processing]
Role_Tools[Role-based Tools<br/>13 Specialized Tools]
end
end
subgraph "Data Layer"
InMemory_State[In-Memory State<br/>Project Data Storage]
Template_Store[Template Store<br/>Document Templates]
end
MCP_Clients --> Core_Server
Core_Server --> Role_Manager
Core_Server --> Project_State
Core_Server --> Tool_Handlers
Core_Server --> Validation_Manager
Core_Server --> Template_Manager
Tool_Handlers --> Gherkin_Parser
Tool_Handlers --> Role_Tools
Project_State --> InMemory_State
Template_Manager --> Template_Store
graph LR
subgraph "Development Stages"
PM[Product Manager<br/>Requirements & Specs]
ARCH[Architect<br/>System Design]
DEV[Developer<br/>Implementation]
TEST[Tester<br/>Quality Assurance]
end
subgraph "Workflow Process"
Start[Start Project] --> PM
PM --> |Create Specs| ARCH
ARCH --> |Design System| DEV
DEV --> |Implement Code| TEST
TEST --> |Execute Tests| End[Project Complete]
PM -.-> |Review Requirements| PM
ARCH -.-> |Refine Design| ARCH
DEV -.-> |Write Tests| DEV
TEST -.-> |Generate Reports| TEST
end
subgraph "Role Transitions"
Switch_Role[switch_role<br/>Tool]
end
PM --> Switch_Role
ARCH --> Switch_Role
DEV --> Switch_Role
TEST --> Switch_Role
specwrite-mcp/
βββ main.py # Entry point
βββ specwrite_mcp/ # Main package
β βββ core/ # Core server functionality
β β βββ __init__.py
β β βββ server.py # MCP server implementation
β βββ handlers/ # Tool handlers
β β βββ __init__.py
β β βββ tool_handlers.py # Tool execution logic
β βββ tools/ # Role-specific tools
β β βββ __init__.py
β β βββ role_manager.py # Role management
β β βββ gherkin_parser.py # BDD parsing
β βββ state/ # Project state management
β β βββ __init__.py
β β βββ project_state.py # State tracking
β βββ utils/ # Utilities
β β βββ __init__.py
β β βββ template_manager.py # Template management
β βββ validation/ # Content validation
β β βββ __init__.py
β β βββ validation_manager.py # Validation logic
β βββ __init__.py
βββ tests/ # Test files
β βββ __init__.py
β βββ test_server.py # Basic server tests
β βββ test_comprehensive.py # Comprehensive tests
βββ README.md # Documentation
- Purpose: Main MCP server implementation
- Responsibilities:
- MCP protocol handling
- Tool registration and routing
- Component coordination
- Key Methods:
handle_list_tools(),handle_call_tool()
- Purpose: Manages development roles and access control
- Features:
- Four predefined roles (Product Manager, Architect, Developer, Tester)
- Role-based tool access control
- Dynamic role switching
- Key Methods:
get_roles(),can_use_tool(),switch_role()
- Purpose: Central hub for all tool operations
- Responsibilities:
- Tool registration and discovery
- Role-based access validation
- Tool execution routing
- Key Methods:
list_tools(),call_tool()
- Purpose: Tracks project progress across development stages
- Features:
- Specification storage
- Implementation tracking
- Test result management
- Progress reporting
- Purpose: Processes Gherkin feature files for BDD scenarios
- Features:
- Feature parsing and validation
- Scenario extraction
- Step analysis
- Structured JSON output
- Purpose: Validates content quality and completeness
- Features:
- Specification validation
- Architecture design validation
- Implementation quality checks
- Test plan completeness
- Purpose: Provides document templates for consistent output
- Features:
- Specification templates
- Architecture templates
- Implementation templates
- Test plan templates
Roles and tools can be extended by modifying the role configuration in specwrite_mcp/tools/role_manager.py.
The project state is currently in-memory. For persistence, you can extend the ProjectState class to add database or file storage.
Add new tools by:
- Adding to role configuration
- Implementing tool logic in the server
- Adding appropriate input schemas
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
MIT License - see LICENSE file for details.
For issues and questions:
- Create an issue on GitHub
- Check the test files for usage examples
- Review the comprehensive test suite
- Persistent state storage
- Additional role types
- Enhanced Gherkin validation
- Integration with popular project management tools
- Web dashboard for project tracking
- Advanced reporting and analytics