Skip to content

Commit 29b5a75

Browse files
Merge pull request AndyEverything#2 from addictivedev/migrate-to-uv-environment-management
Migrate to uv for Python environment management
2 parents e457ecc + f48c459 commit 29b5a75

4 files changed

Lines changed: 1427 additions & 17 deletions

File tree

README.md

Lines changed: 97 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,61 @@ A Model Context Protocol (MCP) server that provides seamless integration with [O
1717

1818
## Prerequisites
1919

20-
- Python 3.8 or higher
20+
- Python 3.10 or higher
21+
- [uv](https://docs.astral.sh/uv/) (fast Python package manager)
2122
- An OpenProject instance (cloud or self-hosted)
2223
- OpenProject API key (generated from your user profile)
2324

2425
## Installation
2526

26-
1. Clone the repository:
27+
### 1. Install uv (if not already installed)
28+
29+
**macOS/Linux:**
30+
```bash
31+
curl -LsSf https://astral.sh/uv/install.sh | sh
32+
```
33+
34+
**Windows:**
35+
```powershell
36+
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
37+
```
38+
39+
**Alternative (using pip):**
40+
```bash
41+
pip install uv
42+
```
43+
44+
### 2. Clone and Setup the Project
45+
2746
```bash
2847
git clone https://github.com/yourusername/openproject-mcp.git
2948
cd openproject-mcp
3049
```
3150

32-
2. Create a virtual environment:
51+
### 3. Create Virtual Environment and Install Dependencies
52+
3353
```bash
34-
python -m venv venv
35-
source venv/bin/activate # On Windows: venv\Scripts\activate
54+
# Create virtual environment and install dependencies in one command
55+
uv sync
3656
```
3757

38-
3. Install dependencies:
58+
**Alternative (manual steps):**
3959
```bash
40-
pip install -r requirements.txt
60+
# Create virtual environment
61+
uv venv
62+
63+
# Install dependencies
64+
uv pip install -r requirements.txt
4165
```
4266

43-
4. Copy the environment template:
67+
### 4. Configure Environment
68+
4469
```bash
45-
cp .env.example .env
70+
# Copy the environment template
71+
cp env_example.txt .env
4672
```
4773

48-
5. Edit `.env` and add your OpenProject configuration:
74+
Edit `.env` and add your OpenProject configuration:
4975
```env
5076
OPENPROJECT_URL=https://your-instance.openproject.com
5177
OPENPROJECT_API_KEY=your-api-key-here
@@ -75,7 +101,17 @@ OPENPROJECT_API_KEY=your-api-key-here
75101

76102
### Running the Server
77103

104+
**Using uv (recommended):**
105+
```bash
106+
uv run python openproject-mcp.py
107+
```
108+
109+
**Alternative (manual activation):**
78110
```bash
111+
# Activate virtual environment
112+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
113+
114+
# Run the server
79115
python openproject-mcp.py
80116
```
81117

@@ -92,13 +128,33 @@ Add this configuration to your Claude Desktop config file:
92128
{
93129
"mcpServers": {
94130
"openproject": {
95-
"command": "python",
96-
"args": ["path/to/openproject-mcp.py"]
131+
"command": "/path/to/your/project/.venv/bin/python",
132+
"args": ["/path/to/your/project/openproject-mcp.py"]
133+
}
134+
}
135+
}
136+
```
137+
138+
**Note:** Replace `/path/to/your/project/` with the actual path to your project directory.
139+
140+
**Alternative with uv (if uv is in your system PATH):**
141+
```json
142+
{
143+
"mcpServers": {
144+
"openproject": {
145+
"command": "uv",
146+
"args": ["run", "python", "/path/to/your/project/openproject-mcp.py"]
97147
}
98148
}
99149
}
100150
```
101151

152+
**Why use the direct Python path?**
153+
The direct Python path approach is more reliable because:
154+
- It doesn't require `uv` to be in the system PATH
155+
- It avoids potential issues with `uv run` trying to install the project as a package
156+
- It's simpler and more straightforward for MCP server configurations
157+
102158
### Available Tools
103159

104160
#### 1. `test_connection`
@@ -445,17 +501,43 @@ Get detailed information about a specific work package relation.
445501

446502
## Development
447503

504+
### Setting up Development Environment
505+
506+
```bash
507+
# Install development dependencies
508+
uv sync --extra dev
509+
510+
# Or install manually
511+
uv pip install -e ".[dev]"
512+
```
513+
448514
### Running Tests
449515

450516
```bash
451-
pytest tests/
517+
uv run pytest tests/
452518
```
453519

454520
### Code Formatting
455521

456522
```bash
457-
black openproject-mcp.py
458-
flake8 openproject-mcp.py
523+
# Format code
524+
uv run black openproject-mcp.py
525+
526+
# Lint code
527+
uv run flake8 openproject-mcp.py
528+
```
529+
530+
### Adding Dependencies
531+
532+
```bash
533+
# Add a new dependency
534+
uv add package-name
535+
536+
# Add a development dependency
537+
uv add --dev package-name
538+
539+
# Update dependencies
540+
uv sync
459541
```
460542

461543
## Tool Compatibility & Test Results

env_example.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
OPENPROJECT_URL=https://your-instance.openproject.com
66

77
# Required: Your OpenProject API key
8-
# Get it from: User Profile -> Access tokens -> Create new token
8+
# Get it from: User Menu (top right) -> Account Settings -> Access tokens -> Create new token ("+ Api Token" button)
99
OPENPROJECT_API_KEY=your-api-key-here
1010

1111
# Optional: HTTP proxy URL (leave empty for direct connection)
@@ -16,4 +16,4 @@ OPENPROJECT_PROXY=
1616
LOG_LEVEL=INFO
1717

1818
# Optional: Test connection on startup (true/false)
19-
TEST_CONNECTION_ON_STARTUP=false
19+
TEST_CONNECTION_ON_STARTUP=true

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[project]
2+
name = "openproject-mcp-server"
3+
version = "1.0.0"
4+
description = "A Model Context Protocol (MCP) server for OpenProject API v3 integration"
5+
authors = [
6+
{name = "Your Name", email = "your.email@example.com"}
7+
]
8+
readme = "README.md"
9+
license = {text = "MIT"}
10+
requires-python = ">=3.10"
11+
keywords = ["mcp", "openproject", "api", "project-management"]
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: MIT License",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
]
21+
22+
dependencies = [
23+
"mcp>=1.0.0",
24+
"aiohttp>=3.8.0",
25+
"python-dotenv>=1.0.0",
26+
"certifi>=2022.0.0",
27+
]
28+
29+
[project.optional-dependencies]
30+
dev = [
31+
"pytest>=7.0.0",
32+
"black>=22.0.0",
33+
"flake8>=4.0.0",
34+
]
35+
36+
[build-system]
37+
requires = ["hatchling"]
38+
build-backend = "hatchling.build"
39+
40+
[tool.black]
41+
line-length = 88
42+
target-version = ['py38']
43+
44+
[tool.flake8]
45+
max-line-length = 88
46+
extend-ignore = ["E203", "W503"]

0 commit comments

Comments
 (0)