-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.html
More file actions
302 lines (276 loc) · 11.7 KB
/
tutorial.html
File metadata and controls
302 lines (276 loc) · 11.7 KB
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Use S2SP in Claude - S2SP Protocol</title>
<link rel="stylesheet" href="../css/style.css">
<style>
.video-container {
margin: 24px 0;
border-radius: 12px;
overflow: hidden;
border: 1px solid var(--border);
background: #000;
}
.video-container video {
width: 100%;
display: block;
}
.step-number {
display: inline-flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 50%;
background: var(--green);
color: #000;
font-weight: 700;
font-size: 14px;
margin-right: 10px;
flex-shrink: 0;
}
.step-header {
display: flex;
align-items: center;
margin-bottom: 8px;
}
.config-block {
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
padding: 20px;
margin: 16px 0;
}
.config-block h4 {
margin-top: 0;
color: var(--text-secondary);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1px;
}
</style>
</head>
<body>
<nav class="nav">
<div class="nav-inner">
<a href="../index.html" class="nav-logo">
<img src="../images/s2sp_icon.png" class="logo-icon" alt="S2SP">
S2SP Protocol
</a>
<ul class="nav-links">
<li><a href="../index.html">Home</a></li>
<li><a href="introduction.html">Docs</a></li>
<li><a href="protocol.html">Protocol</a></li>
<li><a href="sdk.html">SDK</a></li>
<li><a href="demos.html">Examples</a>
</li>
</ul>
</div>
</nav>
<div class="doc-layout">
<aside class="sidebar">
<div class="sidebar-section">
<h4>Getting Started</h4>
<a href="introduction.html">Introduction</a>
<a href="introduction.html#quick-start" class="sub">Quick Start</a>
</div>
<div class="sidebar-section">
<h4>Learn</h4>
<a href="protocol.html">Protocol Design</a>
</div>
<div class="sidebar-section">
<h4>Develop</h4>
<a href="sdk.html">Python SDK</a>
</div>
<div class="sidebar-section">
<h4>Examples</h4>
<a href="demos.html">Agent Development with S2SP</a>
<a href="tutorial.html" class="active">Use S2SP Servers in Claude</a>
</div>
</aside>
<main class="doc-content">
<h1>Use S2SP Servers in Claude</h1>
<p>
This tutorial shows how to connect two S2SP-enabled MCP servers to
Claude Desktop and use natural language to generate weather alert
statistics — with the S2SP protocol automatically splitting data
between the control plane (what Claude sees) and the data plane
(what flows directly between servers).
</p>
<h2>Demo Video</h2>
<p>
Watch Claude orchestrate the weather server and stats server in real time.
Claude decides which fields to request as abstract domains, filters the
alerts, and tells the stats server to generate a chart — all from a
single natural language prompt.
</p>
<div class="video-container">
<video controls preload="metadata">
<source src="../images/demo_video.mov" type="video/quicktime">
<source src="../images/demo_video.mov" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<h2>Prerequisites</h2>
<ul>
<li><a href="https://claude.ai/download">Claude Desktop</a> installed</li>
<li>Python 3.10+ with the project's virtual environment set up</li>
<li>The S2SP repository cloned and installed:
<div class="code-block">
<pre><span class="string">$</span> git clone <repo-url>
<span class="string">$</span> cd S2S_protocol
<span class="string">$</span> pip install -e ".[demos]"</pre>
</div>
</li>
</ul>
<h2>Setup</h2>
<div class="step-header">
<span class="step-number">1</span>
<h3 style="margin:0">Find your Python path</h3>
</div>
<p>You need the absolute path to the project's Python interpreter:</p>
<div class="code-block">
<pre><span class="string">$</span> cd /path/to/S2S_protocol
<span class="string">$</span> echo "$(pwd)/.venv/bin/python"
<span class="comment"># Example: /Users/you/S2S_protocol/.venv/bin/python</span></pre>
</div>
<div class="step-header">
<span class="step-number">2</span>
<h3 style="margin:0">Configure Claude Desktop</h3>
</div>
<p>
Open the Claude Desktop configuration file:
</p>
<div class="code-block">
<pre><span class="comment"># macOS</span>
<span class="string">$</span> open ~/Library/Application\ Support/Claude/claude_desktop_config.json
<span class="comment"># Or create it if it doesn't exist</span>
<span class="string">$</span> mkdir -p ~/Library/Application\ Support/Claude
<span class="string">$</span> nano ~/Library/Application\ Support/Claude/claude_desktop_config.json</pre>
</div>
<p>
Add the two MCP servers. Replace the Python path with your own:
</p>
<div class="config-block">
<h4>claude_desktop_config.json</h4>
<div class="code-block" style="margin:0">
<pre>{
<span class="string">"mcpServers"</span>: {
<span class="string">"weather"</span>: {
<span class="string">"command"</span>: <span class="string">"/path/to/S2S_protocol/.venv/bin/python"</span>,
<span class="string">"args"</span>: [<span class="string">"/path/to/S2S_protocol/demos/weather_agent/weather_server.py"</span>]
},
<span class="string">"stats"</span>: {
<span class="string">"command"</span>: <span class="string">"/path/to/S2S_protocol/.venv/bin/python"</span>,
<span class="string">"args"</span>: [<span class="string">"/path/to/S2S_protocol/demos/weather_agent/stats_server.py"</span>]
}
}
}</pre>
</div>
</div>
<div class="step-header">
<span class="step-number">3</span>
<h3 style="margin:0">Restart Claude Desktop</h3>
</div>
<p>
Quit and reopen Claude Desktop. You should see the two servers in the
tools panel (click the hammer icon):
</p>
<ul>
<li><strong>weather</strong> — <code>get_alerts</code>, <code>get_forecast</code></li>
<li><strong>stats</strong> — <code>draw_chart</code></li>
</ul>
<h2>Usage</h2>
<div class="step-header">
<span class="step-number">4</span>
<h3 style="margin:0">Ask Claude in natural language</h3>
</div>
<p>Just ask what you want. Claude will figure out which fields to request,
how to filter, and when to call the stats server:</p>
<div class="code-block">
<pre><span class="comment"># Try these prompts:</span>
<span class="string">"Can you get the weather alert statistics about the wind in California?"</span>
<span class="string">"Show me severe weather alerts in Texas and generate a chart"</span>
<span class="string">"What urgent alerts are active in Florida? Draw statistics."</span>
<span class="string">"Get all weather alerts for New York and chart them by event type"</span></pre>
</div>
<h2>What Happens Behind the Scenes</h2>
<p>When you ask <em>"Get wind alert statistics for California"</em>, Claude:</p>
<div class="step-header">
<span class="step-number">1</span>
<h3 style="margin:0">Chooses abstract domains</h3>
</div>
<p>
Claude reads your prompt and decides it needs the <code>event</code> field
to filter for wind alerts, plus <code>severity</code> for context. It calls:
</p>
<div class="code-block">
<pre>get_alerts(area=<span class="string">"CA"</span>, abstract_domains=<span class="string">"event,severity"</span>)</pre>
</div>
<p>
The weather server returns only those 2 fields + <code>_row_id</code> per alert
(~600 tokens), plus a <code>resource_url</code>
pointing to the full cached data (~9,000 tokens, not sent to Claude).
</p>
<div class="step-header">
<span class="step-number">2</span>
<h3 style="margin:0">Filters on the control plane</h3>
</div>
<p>
Claude examines the abstract rows and selects those where
<code>event</code> contains "Wind":
</p>
<div class="code-block">
<pre><span class="comment"># Claude sees (control plane):</span>
[{<span class="string">"_row_id"</span>: 0, <span class="string">"event"</span>: <span class="string">"Wind Advisory"</span>, <span class="string">"severity"</span>: <span class="string">"Moderate"</span>},
{<span class="string">"_row_id"</span>: 1, <span class="string">"event"</span>: <span class="string">"Flood Watch"</span>, <span class="string">"severity"</span>: <span class="string">"Minor"</span>}, <span class="comment"># skipped</span>
{<span class="string">"_row_id"</span>: 2, <span class="string">"event"</span>: <span class="string">"High Wind Warning"</span>, <span class="string">"severity"</span>: <span class="string">"Severe"</span>},
...]</pre>
</div>
<div class="step-header">
<span class="step-number">3</span>
<h3 style="margin:0">Calls draw_chart with resource reference</h3>
</div>
<p>
Claude passes the filtered abstract rows and the resource reference to
the stats server:
</p>
<div class="code-block">
<pre>draw_chart(
abstract_data=<span class="string">'[{"_row_id":0,"event":"Wind Advisory","severity":"Moderate"}, ...]'</span>,
resource_url=<span class="string">"http://127.0.0.1:54321/s2sp/data/dK7x_..."</span>
)</pre>
</div>
<div class="step-header">
<span class="step-number">4</span>
<h3 style="margin:0">Stats server fetches body data (data plane)</h3>
</div>
<p>
The stats server connects <strong>directly</strong> to the weather server's
data plane — <code>POST /s2sp/data/dK7x_...45</code> — and gets the
full alert data (description, instruction, sender, parameters, etc.) for the
selected rows. Claude never sees this data.
</p>
<div class="step-header">
<span class="step-number">5</span>
<h3 style="margin:0">Chart displayed inline</h3>
</div>
<p>
The stats server generates an 8-panel chart and returns it as an image.
Claude Desktop displays it directly in the conversation alongside a
text summary of the statistics.
</p>
<h2>More</h2>
<p>
For MCP Inspector debugging, scripted demos, and implementation details,
see <a href="demos.html">Agent Development with S2SP</a>.
</div>
</main>
</div>
<footer class="footer">
<p>S2SP Protocol — An open extension for MCP.</p>
</footer>
</body>
</html>