Skip to content

Commit fab8535

Browse files
committed
claud sesh
1 parent 3ee02fc commit fab8535

13 files changed

Lines changed: 73950 additions & 1741 deletions

File tree

‎docs/dev/v5/build/bendystraw.md‎

Lines changed: 701 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/dev/v5/build/sdk.md‎

Lines changed: 1548 additions & 0 deletions
Large diffs are not rendered by default.

‎docs/dev/v5/build/subgraph.md‎

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,46 @@
11
---
2-
sidebar_position: 4
2+
sidebar_position: 6
33
---
44

5-
# Subgraph
5+
# Subgraph (Legacy)
66

7-
The Juicebox subgraphs index events from the Juicebox contracts, and provide data to apps like [Crypto Fundraising & DAO Management](https://juicebox.money) and [Revnets](https://app.revnet.eth.sucks).
7+
:::tip Recommended: Use Bendystraw
8+
For V5 protocol data, we recommend using [Bendystraw](/docs/dev/v5/build/bendystraw.md) - a modern GraphQL API with better performance, cross-chain support, and active maintenance.
9+
:::
810

9-
There are two subgraph versions: one for legacy contracts versions 1-3, and another for the current v5 contracts. Both maintain extensive, up-to-date data reflecting nearly every aspect of the contracts, including Projects (or Revents) and their balances/configurations, activity events like Payments and Redemptions, token holders, token balances and transfers, and much more.
11+
The legacy Juicebox subgraphs index events from Juicebox contracts V1-V3. These are maintained for backwards compatibility with older projects.
1012

11-
Both subgraphs are developed primarily by Peri (peri.eth, [@peri](https://twitter.com/peri)), and hosted by [Alchemy Subgraphs - By Satsuma](https://subgraph.satsuma-prod.com).
13+
## Legacy Subgraph Access
1214

13-
---
14-
15-
## Querying the subgraph
16-
17-
**URLs:**
18-
Query URLs use this format:
15+
**URL Format:**
1916
```
2017
https://subgraph.satsuma-prod.com/<api-key>/juicebox/<name>/api
21-
```
22-
23-
If you don’t have your own Alchemy subgraphs API key, you can use the free dev key `bc505571c408`, which is restricted by a monthly query limit.
24-
25-
**For current (v5) contracts, Subgraph names follow their network name:**
26-
- ethereum
27-
- sepolia
28-
- base
29-
- base-sepolia
30-
- arbitrum
31-
- arbitrum-sepolia
32-
- optimism
33-
- optimism-sepolia
34-
35-
> **Note:** data from v1-v3 contracts are NOT available in the current (v5) subgraphs.
36-
37-
**For previous contracts (v1-v3), network names are suffixed with `-v3`. Only Ethereum networks are available:**
38-
- ethereum-v3
39-
- sepolia-v3
40-
41-
---
18+
```
4219

43-
## Query structure
20+
**Free dev key:** `bc505571c408` (rate limited)
4421

45-
Juicebox subgraphs accept standard graphql queries. More info [here](https://graphql.org/learn/).
22+
**Available networks (V1-V3 only):**
23+
- `ethereum-v3`
24+
- `sepolia-v3`
4625

47-
You can use Alchemy’s Playground to make sample queries to a specific subgraph, and explore the schema for queryable entities:
26+
**Playground:**
4827
```
4928
https://subgraph.satsuma-prod.com/juicebox/<network>/playground
50-
```
51-
52-
Schemas for each subgraph can also be found on Github.
29+
```
5330

54-
---
31+
## V5 Data
5532

56-
## Github
33+
For V5 protocol data across all chains (Ethereum, Optimism, Arbitrum, Base), use [Bendystraw](/docs/dev/v5/build/bendystraw.md):
5734

58-
- **Current v5:** [peripheralist/nana-subgraph: 🧃 Juicebox Subgraph implementation.](https://github.com/peripheralist/nana-subgraph)
59-
- **Previous versions 1-3:** [jbx-protocol/juice-subgraph: 🧃 Juicebox Subgraph implementation.](https://github.com/jbx-protocol/juice-subgraph)
35+
| Feature | Legacy Subgraph | Bendystraw |
36+
|---------|-----------------|------------|
37+
| Protocol versions | V1-V3 only | V5 |
38+
| Chains | Ethereum only | Ethereum, Optimism, Arbitrum, Base |
39+
| Cross-chain queries | No | Yes (Sucker Groups) |
40+
| SDK integration | Manual | `useBendystrawQuery` hook |
41+
| Maintenance | Minimal | Active |
6042

61-
See the Readme in each repo for more information on development/contributing.
43+
## Source Code
6244

45+
- **V1-V3 Subgraph:** [jbx-protocol/juice-subgraph](https://github.com/jbx-protocol/juice-subgraph)
46+
- **Bendystraw (V5):** [peripheralist/bendystraw](https://github.com/peripheralist/bendystraw)

‎mcp-server/README.md‎

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Juicebox Docs MCP Server
22

3-
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that provides AI assistants with structured access to Juicebox documentation.
3+
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that provides AI assistants with structured access to Juicebox documentation, SDK references, contract addresses, code examples, and integration patterns.
44

55
## Quick Start
66

@@ -18,6 +18,20 @@ curl -X POST https://docs.juicebox.money/api/mcp/search \
1818
curl -X POST https://docs.juicebox.money/api/mcp/get-doc \
1919
-H "Content-Type: application/json" \
2020
-d '{"path": "dev/v5/learn/overview.md"}'
21+
22+
# Get contract addresses
23+
curl "https://docs.juicebox.money/api/mcp/contracts?contract=JBController"
24+
25+
# Get SDK reference
26+
curl "https://docs.juicebox.money/api/mcp/sdk?package=juice-sdk-react&category=write"
27+
28+
# Get integration patterns for revnets
29+
curl "https://docs.juicebox.money/api/mcp/patterns?projectType=revnet"
30+
31+
# Search code examples
32+
curl -X POST https://docs.juicebox.money/api/mcp/search-code \
33+
-H "Content-Type: application/json" \
34+
-d '{"query": "pay", "language": "solidity", "limit": 5}'
2135
```
2236

2337
**JavaScript:**
@@ -42,29 +56,67 @@ npm run mcp:build-index
4256

4357
## API Endpoints
4458

59+
### Documentation
60+
4561
| Method | Endpoint | Description |
4662
|--------|----------|-------------|
4763
| `POST` | `/api/mcp/search` | Search docs (query, category, version, limit) |
4864
| `POST` | `/api/mcp/get-doc` | Get full document by path or title |
4965
| `GET` | `/api/mcp/list-docs?category=developer&version=v5` | List docs in category |
5066
| `GET` | `/api/mcp/structure` | Get documentation structure/stats |
5167

52-
**Parameters:**
68+
### Code & Integration (New)
69+
70+
| Method | Endpoint | Description |
71+
|--------|----------|-------------|
72+
| `POST` | `/api/mcp/search-code` | Search code examples by language/category |
73+
| `GET` | `/api/mcp/contracts` | Get contract addresses by name/chain |
74+
| `GET` | `/api/mcp/sdk` | Get SDK hook/utility reference |
75+
| `GET` | `/api/mcp/patterns` | Get integration patterns by project type |
76+
77+
**Documentation Parameters:**
5378
- `query` (string, required for search): Search terms
5479
- `category`: `developer` | `user` | `dao` | `ecosystem` | `all`
5580
- `version`: `v3` | `v4` | `v5` | `all`
5681
- `limit` (number): Max results (default: 10)
5782
- `path` (string, required for get-doc): Document path or title
5883

84+
**Code Search Parameters:**
85+
- `query` (string, required): Code search terms
86+
- `language`: `solidity` | `typescript` | `javascript` | `json` | `graphql` | `bash` | `all`
87+
- `category`: `contract` | `sdk-react` | `web3` | `api` | `config` | `cli` | `graphql` | `all`
88+
89+
**Contract Address Parameters:**
90+
- `contract`: Contract name (e.g., `JBController`, `REVDeployer`)
91+
- `chainId`: `1` (mainnet) | `10` (optimism) | `8453` (base) | `42161` (arbitrum) | testnets | `all`
92+
- `category`: `core` | `revnet` | `hooks` | `suckers` | `omnichain` | `croptop` | `all`
93+
94+
**SDK Reference Parameters:**
95+
- `package`: `juice-sdk-react` | `juice-sdk-core` | `revnet-sdk` | `all`
96+
- `hook`: Specific hook/utility name (e.g., `useJBProjectProvider`)
97+
- `category`: `context` | `read` | `write` | `omnichain` | `math` | `formatting` | `all`
98+
99+
**Integration Patterns Parameters:**
100+
- `pattern`: Pattern ID (e.g., `pay-project`, `wagmi-setup`)
101+
- `category`: `setup` | `payments` | `calculations` | `data` | `deployment` | `omnichain` | `all`
102+
- `projectType`: `crowdfunding` | `revnet` | `dao-treasury` | `subscription`
103+
59104
## MCP Tools (Stdio Server)
60105

61106
When using the local stdio MCP server:
62107

108+
### Documentation Tools
63109
- `search_docs` - Search documentation by keyword or phrase
64110
- `get_doc` - Retrieve a specific documentation page
65111
- `list_docs_by_category` - List all docs in a category
66112
- `get_doc_structure` - Get the complete documentation structure
67113

114+
### Code & Integration Tools (New)
115+
- `search_code_examples` - Search code examples from documentation
116+
- `get_contract_addresses` - Get contract addresses by name/chain
117+
- `get_sdk_reference` - Get SDK hooks and utilities reference
118+
- `get_integration_patterns` - Get integration patterns and templates
119+
68120
## Configuration
69121

70122
### Claude Desktop
@@ -87,10 +139,14 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
87139

88140
## Features
89141

90-
- **Semantic Search**: Fuzzy search across all documentation
91-
- **Category Filtering**: Filter by developer, user, dao, or ecosystem docs
142+
- **Semantic Search**: Fuzzy search across 1,600+ documentation pages
143+
- **Code Examples**: 8,000+ indexed code examples from docs (Solidity, TypeScript, GraphQL)
144+
- **SDK Reference**: juice-sdk-react hooks, juice-sdk-core utilities, revnet-sdk functions
145+
- **Contract Addresses**: All V5 contract addresses across 8 chains (mainnet + testnets)
146+
- **Integration Patterns**: Ready-to-use code patterns for common use cases
147+
- **Project Type Templates**: Patterns organized by project type (revnet, crowdfunding, DAO, subscription)
92148
- **Version Filtering**: Filter by protocol version (v3, v4, v5)
93-
- **Full Document Retrieval**: Get complete markdown content with metadata
149+
- **Category Filtering**: Filter by developer, user, dao, or ecosystem docs
94150
- **Always Up-to-Date**: Index automatically rebuilds when docs change
95151

96152
## Development

‎mcp-server/src/build-index.js‎

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
/**
44
* Standalone script to build the documentation index
55
* Can be run independently or as part of the build process
6+
*
7+
* Enhanced to extract:
8+
* - Code examples with language tags
9+
* - Contract addresses
10+
* - SDK usage patterns
611
*/
712

813
import fs from "fs/promises";
@@ -16,10 +21,69 @@ const __dirname = path.dirname(__filename);
1621
const PROJECT_ROOT = path.resolve(__dirname, "../..");
1722
const DOCS_DIR = path.join(PROJECT_ROOT, "docs");
1823
const INDEX_FILE = path.join(__dirname, "docs-index.json");
24+
const CODE_EXAMPLES_FILE = path.join(__dirname, "code-examples-index.json");
25+
26+
/**
27+
* Extract code blocks from markdown content
28+
* Returns array of { language, code, context } objects
29+
*/
30+
function extractCodeBlocks(content, docTitle, docPath) {
31+
const codeBlocks = [];
32+
// Match fenced code blocks with optional language
33+
const codeRegex = /```(\w+)?\n([\s\S]*?)```/g;
34+
let match;
35+
36+
while ((match = codeRegex.exec(content)) !== null) {
37+
const language = match[1] || "text";
38+
const code = match[2].trim();
39+
40+
// Skip very short code blocks (likely not useful examples)
41+
if (code.length < 20) continue;
42+
43+
// Get surrounding context (heading before the code block)
44+
const beforeCode = content.substring(0, match.index);
45+
const headingMatch = beforeCode.match(/#{1,6}\s+(.+)$/m);
46+
const context = headingMatch ? headingMatch[1].trim() : docTitle;
47+
48+
// Categorize the code example
49+
let category = "general";
50+
if (language === "solidity" || code.includes("contract ") || code.includes("function ")) {
51+
category = "contract";
52+
} else if (language === "typescript" || language === "javascript" || language === "ts" || language === "js") {
53+
if (code.includes("useWrite") || code.includes("useRead") || code.includes("useJB")) {
54+
category = "sdk-react";
55+
} else if (code.includes("wagmi") || code.includes("viem")) {
56+
category = "web3";
57+
} else if (code.includes("fetch") || code.includes("axios") || code.includes("graphql")) {
58+
category = "api";
59+
} else {
60+
category = "javascript";
61+
}
62+
} else if (language === "json") {
63+
category = "config";
64+
} else if (language === "bash" || language === "shell") {
65+
category = "cli";
66+
} else if (language === "graphql") {
67+
category = "graphql";
68+
}
69+
70+
codeBlocks.push({
71+
language,
72+
code,
73+
context,
74+
category,
75+
docPath,
76+
docTitle,
77+
});
78+
}
79+
80+
return codeBlocks;
81+
}
1982

2083
async function buildIndex() {
2184
console.log("Building documentation index...");
2285
const docIndex = [];
86+
const codeExamples = [];
2387

2488
async function processDirectory(dir, basePath = "") {
2589
const entries = await fs.readdir(dir, { withFileTypes: true });
@@ -124,7 +188,12 @@ async function buildIndex() {
124188
else if (relativePath.startsWith("dev/v5/api/revnet/")) integratorRelevance = 6; // Revnet API
125189
else if (relativePath.startsWith("dev/v5/api/")) integratorRelevance = 3; // Other API lower priority
126190
else if (relativePath.startsWith("dev/v5/")) integratorRelevance = 5;
127-
191+
192+
// Extract code examples from the document
193+
const docTitle = frontmatter.title || headings[0] || path.basename(entry.name, ".md");
194+
const extractedCode = extractCodeBlocks(body, docTitle, relativePath);
195+
codeExamples.push(...extractedCode);
196+
128197
docIndex.push({
129198
path: relativePath,
130199
fullPath: fullPath,
@@ -148,26 +217,41 @@ async function buildIndex() {
148217
}
149218

150219
await processDirectory(DOCS_DIR);
151-
152-
// Save index
220+
221+
// Save documentation index
153222
await fs.writeFile(INDEX_FILE, JSON.stringify(docIndex, null, 2));
154223
console.log(`✓ Indexed ${docIndex.length} documents`);
155224
console.log(`✓ Index saved to ${INDEX_FILE}`);
156-
225+
226+
// Save code examples index
227+
await fs.writeFile(CODE_EXAMPLES_FILE, JSON.stringify(codeExamples, null, 2));
228+
console.log(`✓ Extracted ${codeExamples.length} code examples`);
229+
console.log(`✓ Code examples saved to ${CODE_EXAMPLES_FILE}`);
230+
157231
// Print summary
158232
const byCategory = {};
159233
const byVersion = {};
160-
234+
const codeByCategory = {};
235+
const codeByLanguage = {};
236+
161237
for (const doc of docIndex) {
162238
byCategory[doc.category] = (byCategory[doc.category] || 0) + 1;
163239
if (doc.version) {
164240
byVersion[doc.version] = (byVersion[doc.version] || 0) + 1;
165241
}
166242
}
167-
168-
console.log("\nSummary:");
243+
244+
for (const example of codeExamples) {
245+
codeByCategory[example.category] = (codeByCategory[example.category] || 0) + 1;
246+
codeByLanguage[example.language] = (codeByLanguage[example.language] || 0) + 1;
247+
}
248+
249+
console.log("\nDocumentation Summary:");
169250
console.log("By category:", byCategory);
170251
console.log("By version:", byVersion);
252+
console.log("\nCode Examples Summary:");
253+
console.log("By category:", codeByCategory);
254+
console.log("By language:", codeByLanguage);
171255
}
172256

173257
buildIndex().catch(console.error);

0 commit comments

Comments
 (0)