Skip to content

Commit bd7ac8f

Browse files
authored
Merge pull request #25 from linkml/species
Addition of new species; adding slides
2 parents 04aa1aa + 59372bc commit bd7ac8f

26 files changed

Lines changed: 10502 additions & 826 deletions

cache/ncit/terms.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,4 @@ NCIT:C1752,Peptide Vaccine,2025-10-19T12:15:55.333286
214214
NCIT:C12345,Test Label,2025-10-20T10:35:58.258441
215215
NCIT:C43377,Microplate,2025-10-29T20:43:07.410222
216216
NCIT:C128793,Microplate Well,2025-10-29T20:43:07.418438
217+
NCIT:C103215,Tetrahedral Molecular Geometry,2025-11-07T16:28:22.748298
Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
# Using Common Value Sets with Agentic IDE Support via Context7 MCP
2+
3+
This guide shows you how to leverage Context7 MCP (Model Context Protocol) for enhanced agentic support when working with Common Value Sets in your IDE.
4+
5+
## 🤖 What is Agentic IDE Support?
6+
7+
Agentic IDE support refers to AI assistants that can:
8+
- Access up-to-date documentation in real-time
9+
- Understand your specific codebase context
10+
- Provide accurate code suggestions with proper valuesets
11+
- Execute complex workflows with domain-specific knowledge
12+
13+
Context7 MCP enables this by dynamically fetching current documentation and injecting it into your AI assistant's context.
14+
15+
## 🛠️ Prerequisites
16+
17+
- **Node.js** v18.0.0 or higher
18+
- **Compatible IDE/Editor** with MCP support:
19+
- Claude Desktop
20+
- Cursor
21+
- VS Code with appropriate extensions
22+
- Windsurf
23+
- Zed
24+
- **Common Value Sets** installed in your project
25+
26+
## 📦 Installation & Setup
27+
28+
### 1. Install Context7 MCP Server
29+
30+
#### Option A: Using Smithery CLI (Recommended for Claude Desktop)
31+
```bash
32+
npx -y @smithery/cli install @upstash/context7-mcp --client claude
33+
```
34+
35+
#### Option B: Manual Configuration
36+
37+
For **Claude Desktop**, add to your `claude_desktop_config.json`:
38+
```json
39+
{
40+
"mcpServers": {
41+
"context7": {
42+
"command": "npx",
43+
"args": ["-y", "@upstash/context7-mcp@latest"]
44+
}
45+
}
46+
}
47+
```
48+
49+
For **Cursor**, add to your MCP configuration:
50+
```json
51+
{
52+
"mcpServers": {
53+
"context7": {
54+
"command": "npx",
55+
"args": ["-y", "@upstash/context7-mcp@latest"]
56+
}
57+
}
58+
}
59+
```
60+
61+
For **VS Code**, configure in your settings.json:
62+
```json
63+
{
64+
"mcp.servers": {
65+
"context7": {
66+
"command": "npx",
67+
"args": ["-y", "@upstash/context7-mcp@latest"]
68+
}
69+
}
70+
}
71+
```
72+
73+
### 2. Install Common Value Sets
74+
75+
```bash
76+
pip install valuesets
77+
```
78+
79+
Or add to your requirements:
80+
```txt
81+
valuesets>=0.1.0
82+
```
83+
84+
## 🚀 Usage Patterns
85+
86+
### Basic Pattern: Context-Aware Code Generation
87+
88+
Use the `use context7` directive to get up-to-date valuesets documentation:
89+
90+
**Prompt:**
91+
```
92+
Create a data validation function using Common Value Sets for binary classification. use context7
93+
```
94+
95+
**AI Response will include:**
96+
- Current API documentation for Common Value Sets
97+
- Accurate enum imports and usage
98+
- Proper semantic meaning access
99+
- Version-specific examples
100+
101+
### Advanced Pattern: Domain-Specific Workflows
102+
103+
**Prompt:**
104+
```
105+
Build a bioinformatics pipeline using Common Value Sets for organism taxonomy and experimental techniques. Include validation and semantic mapping. use context7
106+
```
107+
108+
**Expected AI capabilities:**
109+
- Access to current LinkML schema documentation
110+
- Knowledge of available biological enumerations
111+
- Proper ontology term usage (NCBITaxon, OBO terms)
112+
- Integration patterns with semantic web standards
113+
114+
## 🎯 Practical Examples
115+
116+
### Example 1: Data Science Classification
117+
118+
**Prompt:**
119+
```python
120+
# Create a machine learning model validator using Common Value Sets
121+
# Include binary classification, anomaly detection, and fraud detection enums
122+
# use context7
123+
```
124+
125+
**AI will generate:**
126+
```python
127+
from valuesets.enums.data_science.binary_classification import (
128+
BinaryClassificationEnum,
129+
AnomalyDetectionEnum,
130+
FraudDetectionEnum
131+
)
132+
from typing import Union, Dict, Any
133+
import pandas as pd
134+
135+
def validate_predictions(
136+
predictions: pd.Series,
137+
task_type: str
138+
) -> Dict[str, Any]:
139+
"""
140+
Validate model predictions against Common Value Sets standards.
141+
"""
142+
validation_enums = {
143+
'binary': BinaryClassificationEnum,
144+
'anomaly': AnomalyDetectionEnum,
145+
'fraud': FraudDetectionEnum
146+
}
147+
148+
if task_type not in validation_enums:
149+
raise ValueError(f"Unknown task type: {task_type}")
150+
151+
enum_class = validation_enums[task_type]
152+
valid_values = {item.value for item in enum_class}
153+
154+
# Validate predictions
155+
invalid_predictions = predictions[~predictions.isin(valid_values)]
156+
157+
return {
158+
'valid_count': len(predictions) - len(invalid_predictions),
159+
'invalid_count': len(invalid_predictions),
160+
'invalid_values': invalid_predictions.unique().tolist(),
161+
'expected_values': list(valid_values),
162+
'semantic_mappings': {
163+
item.value: item.get_meaning() if hasattr(item, 'get_meaning') else None
164+
for item in enum_class
165+
}
166+
}
167+
168+
# Example usage
169+
predictions = pd.Series(['POSITIVE', 'NEGATIVE', 'MAYBE']) # 'MAYBE' is invalid
170+
result = validate_predictions(predictions, 'binary')
171+
print(f"Validation result: {result}")
172+
```
173+
174+
### Example 2: Bioinformatics Integration
175+
176+
**Prompt:**
177+
```
178+
Create a sample metadata validator for genomics experiments using Common Value Sets. Include organism taxonomy, experimental techniques, and cell cycle phases. use context7
179+
```
180+
181+
**AI will generate:**
182+
```python
183+
from valuesets.enums.bio.taxonomy import CommonOrganismTaxaEnum
184+
from valuesets.enums.bio.cell_cycle import CellCyclePhase
185+
from valuesets.enums.bio.structural_biology import StructuralBiologyTechnique
186+
from dataclasses import dataclass
187+
from typing import Optional, List, Dict
188+
189+
@dataclass
190+
class GenomicsExperiment:
191+
"""
192+
Standardized genomics experiment metadata using Common Value Sets.
193+
"""
194+
organism: CommonOrganismTaxaEnum
195+
technique: StructuralBiologyTechnique
196+
cell_phase: Optional[CellCyclePhase] = None
197+
198+
def validate(self) -> Dict[str, any]:
199+
"""Validate experiment metadata and return semantic information."""
200+
return {
201+
'organism': {
202+
'value': self.organism.value,
203+
'meaning': self.organism.get_meaning(),
204+
'description': self.organism.get_description()
205+
},
206+
'technique': {
207+
'value': self.technique.value,
208+
'meaning': self.technique.get_meaning(),
209+
'description': self.technique.get_description()
210+
},
211+
'cell_phase': {
212+
'value': self.cell_phase.value if self.cell_phase else None,
213+
'meaning': self.cell_phase.get_meaning() if self.cell_phase else None,
214+
'description': self.cell_phase.get_description() if self.cell_phase else None
215+
} if self.cell_phase else None
216+
}
217+
218+
def to_rdf_triples(self) -> List[str]:
219+
"""Convert to RDF triples for semantic web integration."""
220+
triples = []
221+
base_uri = "http://example.org/experiment/"
222+
223+
# Organism triple
224+
if hasattr(self.organism, 'get_meaning') and self.organism.get_meaning():
225+
triples.append(f"<{base_uri}organism> <http://purl.obolibrary.org/obo/RO_0002162> <{self.organism.get_meaning()}> .")
226+
227+
# Technique triple
228+
if hasattr(self.technique, 'get_meaning') and self.technique.get_meaning():
229+
triples.append(f"<{base_uri}technique> <http://purl.obolibrary.org/obo/BFO_0000051> <{self.technique.get_meaning()}> .")
230+
231+
return triples
232+
233+
# Example usage
234+
experiment = GenomicsExperiment(
235+
organism=CommonOrganismTaxaEnum.MOUSE,
236+
technique=StructuralBiologyTechnique.CRYO_EM,
237+
cell_phase=CellCyclePhase.G1
238+
)
239+
240+
print("Validation:", experiment.validate())
241+
print("RDF Triples:", experiment.to_rdf_triples())
242+
```
243+
244+
## 🎪 Advanced Agentic Workflows
245+
246+
### Multi-Step Data Harmonization
247+
248+
**Prompt:**
249+
```
250+
Create an intelligent data harmonization system that:
251+
1. Detects data types in CSV files
252+
2. Maps values to appropriate Common Value Sets enums
253+
3. Suggests ontology alignments
254+
4. Generates standardized output with semantic annotations
255+
use context7
256+
```
257+
258+
With Context7, the AI will have access to:
259+
- Current schema documentation
260+
- All available enum categories
261+
- Ontology mapping patterns
262+
- Best practices for LinkML integration
263+
264+
### Semantic Query Generation
265+
266+
**Prompt:**
267+
```
268+
Build a SPARQL query generator that uses Common Value Sets semantic mappings to create complex biological queries. Include support for GO terms, taxonomy, and experimental conditions. use context7
269+
```
270+
271+
The AI will generate code that properly leverages the ontology term mappings embedded in Common Value Sets.
272+
273+
## 🔧 Configuration Tips
274+
275+
### Optimize Context7 for ValueSets
276+
277+
1. **Custom Documentation Sources**: Configure Context7 to prioritize LinkML and Common Value Sets documentation
278+
2. **Version Pinning**: Ensure Context7 fetches documentation for your specific valuesets version
279+
3. **Domain Focus**: Use domain-specific prompts to get targeted documentation
280+
281+
### IDE-Specific Optimizations
282+
283+
#### For Cursor:
284+
- Enable auto-completion for enum imports
285+
- Configure semantic highlighting for ontology terms
286+
- Set up code actions for value validation
287+
288+
#### For Claude Desktop:
289+
- Use conversation memory for complex workflows
290+
- Leverage file upload for schema validation
291+
- Enable multi-turn planning for data harmonization
292+
293+
#### For VS Code:
294+
- Install LinkML extension for schema validation
295+
- Configure Python language server for enum type hints
296+
- Set up debugging for semantic mapping functions
297+
298+
## 🔍 Troubleshooting
299+
300+
### Common Issues
301+
302+
1. **Context7 not responding**
303+
- Check Node.js version (≥18.0.0)
304+
- Verify MCP configuration syntax
305+
- Restart your IDE
306+
307+
2. **Outdated documentation**
308+
- Clear Context7 cache
309+
- Update to latest Context7 version
310+
- Check internet connectivity
311+
312+
3. **Import errors with valuesets**
313+
- Ensure valuesets is installed in correct environment
314+
- Check Python path configuration
315+
- Verify package version compatibility
316+
317+
### Performance Optimization
318+
319+
- Use specific enum imports rather than wildcard imports
320+
- Cache semantic mappings for repeated lookups
321+
- Batch validation operations when possible
322+
323+
## 🌟 Best Practices
324+
325+
1. **Prompt Engineering**
326+
- Always include "use context7" for up-to-date information
327+
- Be specific about the valuesets domain you're working with
328+
- Ask for semantic mappings when working with ontology integration
329+
330+
2. **Code Organization**
331+
- Group related enums by domain
332+
- Use type hints for better IDE support
333+
- Document semantic mappings in your code
334+
335+
3. **Validation Patterns**
336+
- Validate inputs against enum values
337+
- Leverage semantic meanings for data integration
338+
- Provide clear error messages with valid options
339+
340+
4. **Semantic Integration**
341+
- Use ontology terms for data interoperability
342+
- Generate RDF when needed for knowledge graphs
343+
- Preserve provenance information
344+
345+
## 🚀 Next Steps
346+
347+
- Explore the [Common Value Sets documentation](https://linkml.github.io/valuesets/)
348+
- Learn about [LinkML schemas](https://linkml.io/)
349+
- Check out [Model Context Protocol](https://modelcontextprotocol.io/)
350+
- Contribute new enumerations to the Common Value Sets project
351+
352+
With Context7 MCP and Common Value Sets, you can build intelligent, semantically-aware applications with unprecedented ease and accuracy. The AI assistant becomes your domain expert, providing up-to-date, accurate guidance for standardized data representation across scientific domains.

0 commit comments

Comments
 (0)