Spaces:
Sleeping
Sleeping
File size: 6,400 Bytes
c75526e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | # Setup Guide - OpenProblems Spatial Transcriptomics MCP Server
This guide will help you set up and run the OpenProblems Spatial Transcriptomics MCP Server.
## Prerequisites
### System Requirements
- **Python**: 3.8 or higher
- **Operating System**: Linux, macOS, or Windows (with WSL2 recommended)
- **Memory**: Minimum 4GB RAM (8GB+ recommended for processing large datasets)
- **Storage**: 10GB+ free space for data and temporary files
### Required Tools
The MCP server integrates with these bioinformatics tools:
- **[Nextflow](https://www.nextflow.io/)**: Workflow orchestration
- **[Viash](https://viash.io/)**: Component framework
- **[Docker](https://www.docker.com/)**: Containerization
- **Java**: 11 or higher (required for Nextflow)
## Installation
### Option 1: Local Installation
1. **Clone the repository**:
```bash
git clone https://github.com/openproblems-bio/SpatialAI_MCP.git
cd SpatialAI_MCP
```
2. **Create a Python virtual environment**:
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install the package**:
```bash
pip install -e .
```
4. **Install external tools**:
**Nextflow**:
```bash
curl -s https://get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
```
**Viash**:
```bash
curl -fsSL get.viash.io | bash -s -- --bin /usr/local/bin
```
**Docker**: Follow the [official Docker installation guide](https://docs.docker.com/get-docker/)
### Option 2: Docker Installation
1. **Clone the repository**:
```bash
git clone https://github.com/openproblems-bio/SpatialAI_MCP.git
cd SpatialAI_MCP
```
2. **Build the Docker image**:
```bash
docker build -f docker/Dockerfile -t openproblems-spatial-mcp .
```
3. **Run with Docker Compose**:
```bash
cd docker
docker-compose up -d
```
### Option 3: Development Setup
For contributors and developers:
1. **Clone and install in development mode**:
```bash
git clone https://github.com/openproblems-bio/SpatialAI_MCP.git
cd SpatialAI_MCP
pip install -e ".[dev]"
```
2. **Install pre-commit hooks**:
```bash
pre-commit install
```
3. **Run tests**:
```bash
pytest tests/
```
## Configuration
### Basic Configuration
The server uses `config/server_config.yaml` for configuration. Key settings:
```yaml
server:
name: "OpenProblems-SpatialAI-MCP"
transport:
primary: "stdio"
http_port: 8000
paths:
data_dir: "./data"
work_dir: "./work"
logs_dir: "./logs"
tools:
nextflow:
default_profile: "docker"
viash:
default_engine: "docker"
```
### Environment Variables
You can override configuration with environment variables:
```bash
export MCP_SERVER_NAME="Custom-MCP-Server"
export MCP_DATA_DIR="/custom/data/path"
export MCP_LOG_LEVEL="DEBUG"
```
### Directory Structure
Create the required directories:
```bash
mkdir -p data work logs cache
chmod 755 data work logs cache
```
## Running the Server
### Method 1: Direct Python Execution
```bash
# Start the server
python -m mcp_server.main
# Or use the installed command
openproblems-mcp
```
### Method 2: Docker
```bash
# Run the container
docker run -it --rm \
-v $(pwd)/data:/app/data \
-v $(pwd)/work:/app/work \
-v $(pwd)/logs:/app/logs \
-v /var/run/docker.sock:/var/run/docker.sock \
openproblems-spatial-mcp
```
### Method 3: Docker Compose
```bash
cd docker
docker-compose up
```
## Testing the Installation
### Run the Test Suite
```bash
pytest tests/ -v
```
### Use the Example Client
```bash
python examples/simple_client.py
```
### Manual Testing
1. **Start the server** (in one terminal):
```bash
python -m mcp_server.main
```
2. **Test with MCP client** (in another terminal):
```python
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def test_connection():
server_params = StdioServerParameters(
command="python",
args=["-m", "mcp_server.main"],
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Test echo
result = await session.call_tool("echo_test", {"message": "Hello!"})
print(f"Echo result: {result}")
# List resources
resources = await session.list_resources()
print(f"Available resources: {len(resources)}")
asyncio.run(test_connection())
```
## Troubleshooting
### Common Issues
1. **Import errors**:
- Ensure the package is installed: `pip install -e .`
- Check Python path: `python -c "import mcp_server; print('OK')"`
2. **Tool not found errors**:
- Install missing tools (Nextflow, Viash, Docker)
- Check PATH: `which nextflow`, `which viash`, `which docker`
3. **Permission errors**:
- Ensure Docker daemon is running: `docker version`
- Check directory permissions: `ls -la data/ work/ logs/`
4. **Port conflicts** (HTTP transport):
- Change port in config: `transport.http_port: 8001`
- Check port usage: `netstat -tulpn | grep 8000`
### Debug Mode
Enable debug logging:
```bash
export MCP_LOG_LEVEL=DEBUG
python -m mcp_server.main
```
### Log Files
Check server logs:
```bash
tail -f logs/mcp_server.log
```
### Health Check
Test server health:
```bash
# For Docker containers
docker exec openproblems-spatial-mcp python -c "import mcp; print('MCP SDK available')"
# For local installation
python -c "import mcp_server.main; print('Server module available')"
```
## Next Steps
1. **Read the [API Documentation](API.md)** to understand available tools and resources
2. **Explore [Examples](../examples/)** to see practical usage patterns
3. **Check the [Integration Guide](INTEGRATION.md)** for AI agent setup
4. **Review [Best Practices](BEST_PRACTICES.md)** for optimal usage
## Support
- **Issues**: [GitHub Issues](https://github.com/openproblems-bio/SpatialAI_MCP/issues)
- **Documentation**: [Project Docs](https://github.com/openproblems-bio/SpatialAI_MCP/docs)
- **Community**: [OpenProblems Discussions](https://github.com/openproblems-bio/openproblems/discussions)
## Contributing
See [CONTRIBUTING.md](../CONTRIBUTING.md) for development guidelines and contribution instructions.
|