File size: 5,801 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
# OpenProblems Agent Integration Guide

## Complete Setup Overview

This guide shows how to integrate the **Agent Rules**, **Agent Prompt**, and **Continue.dev Configuration** for optimal spatial transcriptomics AI assistance.

## πŸ“‹ Integration Checklist

### 1. **Continue.dev Configuration**
βœ… **File**: `~/.continue/config.json`
βœ… **Purpose**: Connects Continue.dev to your MCP server
βœ… **Key Component**:
```json
"experimental": {
  "modelContextProtocolServers": [
    {
      "name": "openproblems-spatial",
      "transport": {
        "type": "stdio",
        "command": "python",
        "args": ["-m", "mcp_server.main"],
        "cwd": "/home/obi/SpatialAI_MCP"
      }
    }
  ]
}
```

### 2. **Agent Rules**
βœ… **File**: `docs/AGENT_RULES.md`
βœ… **Purpose**: Comprehensive guidelines for spatial transcriptomics best practices
βœ… **Usage**: Continue.dev agent references these rules automatically when integrated

### 3. **Agent Prompt**
βœ… **File**: `docs/AGENT_PROMPT.md`
βœ… **Purpose**: Sophisticated agent behavior definition
βœ… **Integration**: Add to Continue.dev system prompt or rules section

## πŸ”§ **Final Continue.dev Configuration**

Update your `~/.continue/config.json` to include the agent prompt:

```json
{
  "models": [
    {
      "title": "Claude 3.5 Sonnet",
      "provider": "anthropic",
      "model": "claude-3-5-sonnet-20241022",
      "apiKey": "your-anthropic-api-key-here"
    }
  ],
  "experimental": {
    "modelContextProtocolServers": [
      {
        "name": "openproblems-spatial",
        "transport": {
          "type": "stdio",
          "command": "python",
          "args": ["-m", "mcp_server.main"],
          "cwd": "/home/obi/SpatialAI_MCP"
        }
      }
    ]
  },
  "systemMessage": "You are an expert computational biology assistant specializing in spatial transcriptomics analysis using the OpenProblems framework. You have access to a comprehensive Model Context Protocol (MCP) server with 11 specialized tools and 5 curated knowledge resources. Always start interactions by checking the environment using check_environment tool, then assess project structure with list_directory. Follow the systematic workflow guidelines in AGENT_RULES.md for optimal results.",
  "docs": [
    {
      "title": "Nextflow Documentation",
      "startUrl": "https://www.nextflow.io/docs/latest/"
    },
    {
      "title": "Viash Documentation",
      "startUrl": "https://viash.io/docs/"
    },
    {
      "title": "OpenProblems GitHub",
      "startUrl": "https://github.com/openproblems-bio/openproblems-v2"
    },
    {
      "title": "Spatial Transcriptomics Task",
      "startUrl": "https://github.com/openproblems-bio/task_spatial_decomposition"
    }
  ]
}
```

## πŸš€ **Testing Your Complete Setup**

### Step 1: Verify MCP Server
```bash
cd /home/obi/SpatialAI_MCP
python -m mcp_server.main
# Should start without errors
```

### Step 2: Test Continue.dev Integration
1. **Restart VS Code** after updating config
2. **Open Continue.dev** (Cmd/Ctrl + L)
3. **Test Query**: "Check my spatial transcriptomics environment and help me create a quality control pipeline"

### Step 3: Expected Agent Behavior
The agent should:
- βœ… Use `check_environment` tool first
- βœ… Use `list_directory` to assess project structure
- βœ… Reference OpenProblems best practices
- βœ… Generate Viash-compatible components
- βœ… Create Nextflow DSL2 pipelines
- βœ… Follow all rules from AGENT_RULES.md

## 🎯 **Expected Interaction Flow**

```mermaid
graph TD
    A["πŸ‘©β€πŸ’» User Query<br/>'Help with spatial QC'"] --> B["πŸ€– Agent Assessment<br/>check_environment tool"]
    B --> C["πŸ“ Project Analysis<br/>list_directory tool"]
    C --> D["πŸ“š Rules Reference<br/>AGENT_RULES.md guidelines"]
    D --> E["πŸ› οΈ Solution Creation<br/>write_file + validate tools"]
    E --> F["βœ… Quality Validation<br/>test and verify output"]
    F --> G["πŸ“‹ Comprehensive Response<br/>Code + Documentation + Next Steps"]
```

## πŸ“ **Example Successful Interaction**

**User**: "I need help setting up spatial transcriptomics quality control"

**Agent Response**:
```
I'll help you set up comprehensive spatial transcriptomics quality control. Let me first assess your environment and project structure.

[Uses check_environment tool]
βœ… Docker: Available (v28.1.1)
❌ Nextflow: Not found
❌ Viash: Not found

[Uses list_directory tool]
Found spatial data in: data/spatial_samples/
Existing configs: config/

Based on the OpenProblems best practices, I'll:
1. Install missing dependencies
2. Create a modular QC pipeline
3. Generate Viash components
4. Set up comprehensive testing

[Creates optimized pipeline with proper error handling and documentation]
```

## πŸ” **Troubleshooting**

### Issue: MCP Tools Not Available
**Solution**: Check Continue.dev logs in VS Code Developer Tools
```bash
# Verify MCP server manually
python -m mcp_server.main
openproblems-mcp info
```

### Issue: Agent Not Following Rules
**Solution**: Ensure systemMessage includes rules reference
```json
"systemMessage": "...Follow the systematic workflow guidelines in AGENT_RULES.md..."
```

### Issue: Spatial Analysis Errors
**Solution**: Agent should use validate_nextflow_config tool
```
The agent will automatically validate pipelines using our MCP tools before providing solutions.
```

## πŸŽ‰ **Success Indicators**

Your integration is successful when:
- [ ] Agent proactively uses MCP tools (check_environment, list_directory)
- [ ] Generated code follows OpenProblems conventions
- [ ] Pipelines are properly validated before delivery
- [ ] Documentation includes troubleshooting and next steps
- [ ] Solutions are tested and reproducible

**πŸš€ You now have a complete AI-powered spatial transcriptomics development environment!**