Skip to content

Commit a9080a6

Browse files
authored
feat: oso workflow improvements + gemini tutorial setup (#4808)
* add: `gemini` + `oso` first iteration * eat: add experiment `annotations` with metadata collection * chore: simplify text2sql endpoint to use `semantic` workflow only * feat: add `entity_context` parameter for vector database integration * feat: inject vector database resources into workflow `resolver` * refactor: extract `OsoVectorDatabaseMixin` for better modularity * feat: connect semantic workflows to `vector` database context * add: synthesize and execute flags to semantic query `events` * add: experiment metadata collection utility for `annotations` * fix: update metadata key from 'agent_name' to 'name' in experiment functions * revert: `unique`experiment name * fix: improve `logging` for destructive `dataset` actions * fix: address metadata `feedback`
1 parent 5fb6b07 commit a9080a6

File tree

10 files changed

+763
-105
lines changed

10 files changed

+763
-105
lines changed
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
# Gemini
2+
3+
Open Source Observer (OSO) provides comprehensive Web3 and crypto ecosystem
4+
datasets through an AI-powered interface. This tutorial shows how to use Gemini
5+
CLI with OSO's Model Context Protocol (MCP) server to generate data analysis
6+
notebooks.
7+
8+
In this tutorial, we will walk through the process of setting up and using
9+
Gemini with OSO in 5 minutes.
10+
11+
## What OSO Exposes to Gemini
12+
13+
OSO provides access to curated datasets covering:
14+
15+
- **20+ OP Stack chains** - Transaction data, gas usage, contract deployments
16+
- **Developer activity** - GitHub repos, commits, dependencies for 1000+ crypto
17+
projects
18+
- **DeFi protocols** - TVL, transaction volumes, user activity across chains
19+
- **Funding flows** - Gitcoin grants, Optimism RetroPGF, other ecosystem funding
20+
- **Social data** - Farcaster, Lens protocol activity and social graphs
21+
- **Address labeling** - Bot detection, MEV identification, user categorization
22+
23+
Through our MCP server, Gemini can:
24+
25+
- Query these datasets with natural language
26+
- Generate SQL automatically using our semantic layer
27+
- Create Jupyter notebooks with data visualizations
28+
- Provide full data provenance for reproducible analysis
29+
30+
## Example Use Cases
31+
32+
```
33+
Analyze World Chain mini-app user retention rates over the first 30 days
34+
```
35+
36+
```
37+
Compare TVL growth across Arbitrum vs Optimism over the last 6 months
38+
```
39+
40+
```
41+
Show me the top 10 most active developers in the Ethereum ecosystem
42+
```
43+
44+
## Installing Gemini CLI
45+
46+
Gemini CLI is Google's open-source command line interface that provides access
47+
to Gemini directly in your terminal.
48+
49+
1. **Prerequisites**: You need Node.js version 18 or higher installed on your
50+
machine.
51+
52+
2. **Install Gemini CLI**:
53+
54+
```bash
55+
npm install -g @google/gemini-cli
56+
```
57+
58+
3. **Verify installation**:
59+
60+
```bash
61+
gemini --version
62+
```
63+
64+
4. **Launch Gemini CLI**:
65+
66+
```bash
67+
gemini
68+
```
69+
70+
## Authentication
71+
72+
When you first run Gemini CLI, it will prompt you to select a theme and then
73+
authenticate.
74+
75+
1. **Interactive Authentication**: You'll be prompted to sign in via Google.
76+
Complete the OAuth flow in your browser to authenticate.
77+
78+
2. **Authentication Options**:
79+
80+
- **Login with Google** (Recommended): Provides access to the free tier of
81+
Gemini CLI, which allows for 60 requests/minute, 1000 model requests per
82+
day
83+
- **API Key**: For higher rate limits, get your API key from
84+
[Google AI Studio](https://aistudio.google.com/app/apikey)
85+
- **Vertex AI**: For enterprise use with Google Cloud projects
86+
87+
3. **Using API Key** (if needed):
88+
89+
```bash
90+
# Set environment variable
91+
export GEMINI_API_KEY="your-api-key-here"
92+
93+
# Or create ~/.gemini/.env file with:
94+
# GEMINI_API_KEY=your-api-key-here
95+
```
96+
97+
4. **Switch Authentication**: You can use `/auth` in the Gemini CLI to switch
98+
the authentication method as needed.
99+
100+
## Setting Up OSO MCP Server
101+
102+
The OSO MCP server runs in Docker and uses STDIO transport, which means Gemini
103+
CLI will automatically start and manage the Docker container when needed.
104+
105+
1. **Set your OSO API key as an environment variable**:
106+
107+
```bash
108+
export OSO_API_KEY="your-oso-api-key-here"
109+
```
110+
111+
Get your API key from [OSO Dashboard](https://www.opensource.observer/).
112+
113+
**Or create `~/.gemini/.env` file**:
114+
115+
```
116+
OSO_API_KEY=your-oso-api-key-here
117+
```
118+
119+
2. **Configure Gemini CLI**: Create or edit `~/.gemini/settings.json`:
120+
121+
```json
122+
{
123+
"mcpServers": {
124+
"oso": {
125+
"command": "docker",
126+
"args": [
127+
"run",
128+
"--rm",
129+
"-i",
130+
"-e",
131+
"MCP_OSO_API_KEY=$OSO_API_KEY",
132+
"ghcr.io/opensource-observer/oso-mcp",
133+
"--verbose",
134+
"serve"
135+
],
136+
"env": {
137+
"OSO_API_KEY": "$OSO_API_KEY"
138+
},
139+
"timeout": 60000,
140+
"trust": false
141+
}
142+
}
143+
}
144+
```
145+
146+
**Note**: Gemini CLI will automatically start the Docker container when you use
147+
OSO tools and stop it when done.
148+
149+
## Testing the Connection
150+
151+
Verify everything is working by launching Gemini CLI and checking the MCP server
152+
connection.
153+
154+
1. **Launch Gemini CLI**:
155+
156+
```bash
157+
gemini
158+
```
159+
160+
2. **Check MCP server status**:
161+
162+
```
163+
/mcp
164+
```
165+
166+
You should see the OSO server listed. Gemini CLI will automatically start the
167+
Docker container when needed. Try this test prompt:
168+
169+
```
170+
List the available OSO datasets and tell me what World Chain data you have access to
171+
```
172+
173+
If successful, Gemini should respond with information about OSO's datasets
174+
including World Chain user operation data.
175+
176+
## Generating Your First Notebook
177+
178+
Now you're ready to generate analysis notebooks! Try this example:
179+
180+
```
181+
Analyze World Chain mini-app user retention rates over the first 30 days. Create a Jupyter notebook that:
182+
1. Queries World Chain user operation data
183+
2. Calculates daily, weekly, and monthly retention rates
184+
3. Creates a retention curve visualization
185+
4. Exports the notebook to Google Colab format
186+
```
187+
188+
Gemini will:
189+
190+
- Generate the necessary SQL queries using OSO's semantic layer
191+
- Create Python code for data analysis and visualization
192+
- Package everything into a Jupyter notebook
193+
- Provide data provenance information showing exactly which datasets were used
194+
195+
## Expected Output
196+
197+
You should receive:
198+
199+
- A complete `.ipynb` file ready to run in Google Colab
200+
- Clear documentation of data sources and methodology
201+
- Visualizations showing retention trends
202+
- Instructions for uploading to Colab and running the analysis
203+
204+
## Troubleshooting
205+
206+
**MCP server not found:**
207+
208+
- Check the server status: `/mcp` inside Gemini CLI
209+
- Verify Docker is installed and running: `docker --version`
210+
- Ensure your OSO API key environment variable is set: `echo $OSO_API_KEY`
211+
- Check that the Docker image can be pulled:
212+
`docker pull ghcr.io/opensource-observer/oso-mcp`
213+
214+
**OSO MCP server won't start:**
215+
216+
- Verify Docker is installed and running
217+
- Check that your OSO API key is valid
218+
- Ensure Docker has permission to run containers
219+
- Try pulling the image manually first:
220+
`docker pull ghcr.io/opensource-observer/oso-mcp`
221+
222+
**Connection errors:**
223+
224+
- Verify Docker daemon is running: `docker ps`
225+
- Check Docker logs if the container fails to start
226+
- Ensure no firewall is blocking Docker operations
227+
228+
**Authentication errors:**
229+
230+
- Verify your OSO API key environment variable is set: `echo $OSO_API_KEY`
231+
- Check you're logged into Gemini CLI: use `/auth` command
232+
- Verify your API key is valid on the OSO Dashboard
233+
234+
**Data access issues:**
235+
236+
- Verify your OSO account has access to the requested datasets
237+
- Some datasets may require additional permissions
238+
239+
**Installation issues:**
240+
241+
- Ensure npm global folder is in PATH
242+
- Run `npm install -g @google/gemini-cli` to update if you get version issues
243+
244+
## Next Steps
245+
246+
Once you have a working notebook:
247+
248+
1. Upload it to Google Colab
249+
2. Run the analysis to verify results
250+
3. Try variations with different time periods or mini-apps
251+
4. Explore other OSO datasets like DeFi protocols or developer activity

0 commit comments

Comments
 (0)