mcp-ui 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-ui
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A Python SDK for building MCP UI resources (iframe, panels, text blocks, etc.) in a type-safe way.
5
5
  Project-URL: Homepage, https://github.com/jameszokah/mcp-ui
6
6
  Project-URL: Repository, https://github.com/jameszokah/mcp-ui
@@ -22,29 +22,30 @@ Classifier: Programming Language :: Python :: 3.12
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
24
 
25
-
26
25
  # MCP-UI Python SDK
27
26
 
28
27
  This library is a Python port of the MCP-UI TypeScript SDK.
29
- It provides strongly typed helpers for creating UI resources and UI actions in MCP servers, with good DX (developer experience), type safety, and MCP-compatible JSON output.
28
+ It provides strongly typed helpers for creating UI resources and UI actions in MCP servers, with good type safety, and MCP-compatible JSON output.
30
29
 
31
30
  ---
32
31
 
33
32
  ## 📦 Installation
34
33
 
35
- \`\`\`bash
34
+ ```bash
36
35
  pip install mcp-ui
37
- \`\`\`
36
+ ```
38
37
 
39
38
  ---
40
39
 
41
40
  ## 🚀 Core Concepts
42
41
 
43
42
  ### What is a UI Resource?
43
+
44
44
  A **UI resource** is a unit of UI data (e.g., an HTML snippet, iframe, or Remote DOM script) that MCP clients can render.
45
45
  This SDK helps you create them consistently with correct metadata and encodings.
46
46
 
47
47
  ### What is a UI Action?
48
+
48
49
  A **UI action result** represents an action the MCP client should take (e.g., open a link, show a prompt, call a tool).
49
50
 
50
51
  ---
@@ -55,7 +56,7 @@ A **UI action result** represents an action the MCP client should take (e.g., op
55
56
 
56
57
  #### Raw HTML
57
58
 
58
- \`\`\`python
59
+ ```python
59
60
  from mcp_ui import RawHtmlContent, CreateUIResourceOptions, create_ui_resource
60
61
 
61
62
  options = CreateUIResourceOptions(
@@ -66,11 +67,11 @@ options = CreateUIResourceOptions(
66
67
 
67
68
  resource = create_ui_resource(options)
68
69
  print(resource)
69
- \`\`\`
70
+ ```
70
71
 
71
72
  **Output:**
72
73
 
73
- \`\`\`json
74
+ ```json
74
75
  {
75
76
  "type": "resource",
76
77
  "resource": {
@@ -81,11 +82,11 @@ print(resource)
81
82
  "_meta": null
82
83
  }
83
84
  }
84
- \`\`\`
85
+ ```
85
86
 
86
87
  #### External URL (iframe)
87
88
 
88
- \`\`\`python
89
+ ```python
89
90
  from mcp_ui import ExternalUrlContent, CreateUIResourceOptions, create_ui_resource
90
91
 
91
92
  options = CreateUIResourceOptions(
@@ -95,11 +96,11 @@ options = CreateUIResourceOptions(
95
96
  )
96
97
 
97
98
  iframe_res = create_ui_resource(options)
98
- \`\`\`
99
+ ```
99
100
 
100
101
  **Output:**
101
102
 
102
- \`\`\`json
103
+ ```json
103
104
  {
104
105
  "type": "resource",
105
106
  "resource": {
@@ -110,11 +111,11 @@ iframe_res = create_ui_resource(options)
110
111
  "_meta": null
111
112
  }
112
113
  }
113
- \`\`\`
114
+ ```
114
115
 
115
116
  #### Remote DOM (React)
116
117
 
117
- \`\`\`python
118
+ ```python
118
119
  from mcp_ui import RemoteDomContent, CreateUIResourceOptions, create_ui_resource
119
120
 
120
121
  options = CreateUIResourceOptions(
@@ -124,11 +125,11 @@ options = CreateUIResourceOptions(
124
125
  )
125
126
 
126
127
  remote_res = create_ui_resource(options)
127
- \`\`\`
128
+ ```
128
129
 
129
130
  **Output (blob is Base64-encoded):**
130
131
 
131
- \`\`\`json
132
+ ```json
132
133
  {
133
134
  "type": "resource",
134
135
  "resource": {
@@ -139,7 +140,7 @@ remote_res = create_ui_resource(options)
139
140
  "_meta": null
140
141
  }
141
142
  }
142
- \`\`\`
143
+ ```
143
144
 
144
145
  ---
145
146
 
@@ -147,7 +148,7 @@ remote_res = create_ui_resource(options)
147
148
 
148
149
  You can attach metadata to resources. Keys are automatically prefixed with \`mcpui.dev/ui-\`.
149
150
 
150
- \`\`\`python
151
+ ```python
151
152
  options = CreateUIResourceOptions(
152
153
  uri="ui://demo/meta",
153
154
  content=RawHtmlContent(type="rawHtml", htmlString="<p>Meta Example</p>"),
@@ -156,11 +157,11 @@ options = CreateUIResourceOptions(
156
157
  )
157
158
 
158
159
  meta_res = create_ui_resource(options)
159
- \`\`\`
160
+ ```
160
161
 
161
- **Output includes \`_meta\`:**
162
+ **Output includes \`\_meta\`:**
162
163
 
163
- \`\`\`json
164
+ ```json
164
165
  {
165
166
  "type": "resource",
166
167
  "resource": {
@@ -173,7 +174,7 @@ meta_res = create_ui_resource(options)
173
174
  }
174
175
  }
175
176
  }
176
- \`\`\`
177
+ ```
177
178
 
178
179
  ---
179
180
 
@@ -181,14 +182,14 @@ meta_res = create_ui_resource(options)
181
182
 
182
183
  #### Tool Call
183
184
 
184
- \`\`\`python
185
+ ```python
185
186
  from mcp_ui import ui_action_result_tool_call
186
187
  action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
187
- \`\`\`
188
+ ```
188
189
 
189
190
  **Output:**
190
191
 
191
- \`\`\`json
192
+ ```json
192
193
  {
193
194
  "type": "tool",
194
195
  "payload": {
@@ -196,50 +197,50 @@ action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
196
197
  "params": { "query": "MCP SDK" }
197
198
  }
198
199
  }
199
- \`\`\`
200
+ ```
200
201
 
201
202
  #### Prompt
202
203
 
203
- \`\`\`python
204
+ ```python
204
205
  from mcp_ui import ui_action_result_prompt
205
206
  action = ui_action_result_prompt("Please confirm your choice")
206
- \`\`\`
207
+ ```
207
208
 
208
209
  **Output:**
209
210
 
210
- \`\`\`json
211
+ ```json
211
212
  {
212
213
  "type": "prompt",
213
214
  "payload": { "prompt": "Please confirm your choice" }
214
215
  }
215
- \`\`\`
216
+ ```
216
217
 
217
218
  #### Link
218
219
 
219
- \`\`\`python
220
+ ```python
220
221
  from mcp_ui import ui_action_result_link
221
222
  action = ui_action_result_link("https://example.com")
222
- \`\`\`
223
+ ```
223
224
 
224
225
  **Output:**
225
226
 
226
- \`\`\`json
227
+ ```json
227
228
  {
228
229
  "type": "link",
229
230
  "payload": { "url": "https://example.com" }
230
231
  }
231
- \`\`\`
232
+ ```
232
233
 
233
234
  #### Intent
234
235
 
235
- \`\`\`python
236
+ ```python
236
237
  from mcp_ui import ui_action_result_intent
237
238
  action = ui_action_result_intent("share", {"platform": "twitter"})
238
- \`\`\`
239
+ ```
239
240
 
240
241
  **Output:**
241
242
 
242
- \`\`\`json
243
+ ```json
243
244
  {
244
245
  "type": "intent",
245
246
  "payload": {
@@ -247,40 +248,43 @@ action = ui_action_result_intent("share", {"platform": "twitter"})
247
248
  "params": { "platform": "twitter" }
248
249
  }
249
250
  }
250
- \`\`\`
251
+ ```
251
252
 
252
253
  #### Notification
253
254
 
254
- \`\`\`python
255
+ ```python
255
256
  from mcp_ui import ui_action_result_notification
256
257
  action = ui_action_result_notification("Saved successfully!")
257
- \`\`\`
258
+ ```
258
259
 
259
260
  **Output:**
260
261
 
261
- \`\`\`json
262
+ ```json
262
263
  {
263
264
  "type": "notify",
264
265
  "payload": { "message": "Saved successfully!" }
265
266
  }
266
- \`\`\`
267
+ ```
267
268
 
268
269
  ---
269
270
 
270
271
  ## 📖 API Reference
271
272
 
272
273
  ### create_ui_resource(options: CreateUIResourceOptions) → Dict[str, Any]
274
+
273
275
  Creates a UI resource for MCP. Returns a JSON-serializable dict.
274
276
 
275
277
  **Parameters:**
276
- - \`uri\`: must start with \`ui://\`
277
- - \`content\`: one of \`RawHtmlContent\`, \`ExternalUrlContent\`, \`RemoteDomContent\`
278
- - \`encoding\`: \`"text"\` or \`"blob"\`
279
- - \`uiMetadata\`: UI-specific metadata (auto-prefixed)
280
- - \`metadata\`: General metadata
281
- - \`resourceProps\`: Extra resource fields
278
+
279
+ - `uri`: must start with `ui://`
280
+ - `content`: one of `RawHtmlContent`, `ExternalUrlContent`, `RemoteDomContent`
281
+ - `encoding`: `"text"` or `"blob"`
282
+ - `uiMetadata`: UI-specific metadata (auto-prefixed)
283
+ - `metadata`: General metadata
284
+ - `resourceProps`: Extra resource fields
282
285
 
283
286
  **Type System:**
287
+
284
288
  - **Content payloads**:
285
289
  - RawHtmlContent(htmlString)
286
290
  - ExternalUrlContent(iframeUrl)
@@ -296,11 +300,11 @@ Creates a UI resource for MCP. Returns a JSON-serializable dict.
296
300
  ## ⚙️ Notes
297
301
 
298
302
  - Internally uses dataclasses for type safety, but always returns dicts (via \`asdict()\`) for MCP compatibility.
299
- - Enforces URI format (\`ui://\` prefix).
303
+ - Enforces URI format (`ui://` prefix).
300
304
  - Auto-encodes blob resources in Base64.
301
305
 
302
306
  ---
303
307
 
304
308
  ## 📄 License
305
309
 
306
- MIT – same as the original MCP-UI SDK.
310
+ MIT – Similar to the original MCP-UI Typescript server SDK.
@@ -0,0 +1,4 @@
1
+ mcp_ui-0.1.1.dist-info/METADATA,sha256=H5JN3O4f7KVk1NB3c8o_tX_SVNbgwBgm9anL_iR3Dkg,6583
2
+ mcp_ui-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
+ mcp_ui-0.1.1.dist-info/licenses/LICENSE,sha256=pAZXnNE2dxxwXFIduGyn1gpvPefJtUYOYZOi3yeGG94,1068
4
+ mcp_ui-0.1.1.dist-info/RECORD,,
@@ -1,4 +0,0 @@
1
- mcp_ui-0.1.0.dist-info/METADATA,sha256=AdeUTQHlblMMQdW8JJ7CzsbVY0a0PbPQCV7G01UN0mc,6724
2
- mcp_ui-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
- mcp_ui-0.1.0.dist-info/licenses/LICENSE,sha256=pAZXnNE2dxxwXFIduGyn1gpvPefJtUYOYZOi3yeGG94,1068
4
- mcp_ui-0.1.0.dist-info/RECORD,,
File without changes