mcp-ui 0.1.0__tar.gz → 0.1.1__tar.gz

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.
@@ -1,26 +1,27 @@
1
-
2
1
  # MCP-UI Python SDK
3
2
 
4
3
  This library is a Python port of the MCP-UI TypeScript SDK.
5
- 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.
4
+ It provides strongly typed helpers for creating UI resources and UI actions in MCP servers, with good type safety, and MCP-compatible JSON output.
6
5
 
7
6
  ---
8
7
 
9
8
  ## 📦 Installation
10
9
 
11
- \`\`\`bash
10
+ ```bash
12
11
  pip install mcp-ui
13
- \`\`\`
12
+ ```
14
13
 
15
14
  ---
16
15
 
17
16
  ## 🚀 Core Concepts
18
17
 
19
18
  ### What is a UI Resource?
19
+
20
20
  A **UI resource** is a unit of UI data (e.g., an HTML snippet, iframe, or Remote DOM script) that MCP clients can render.
21
21
  This SDK helps you create them consistently with correct metadata and encodings.
22
22
 
23
23
  ### What is a UI Action?
24
+
24
25
  A **UI action result** represents an action the MCP client should take (e.g., open a link, show a prompt, call a tool).
25
26
 
26
27
  ---
@@ -31,7 +32,7 @@ A **UI action result** represents an action the MCP client should take (e.g., op
31
32
 
32
33
  #### Raw HTML
33
34
 
34
- \`\`\`python
35
+ ```python
35
36
  from mcp_ui import RawHtmlContent, CreateUIResourceOptions, create_ui_resource
36
37
 
37
38
  options = CreateUIResourceOptions(
@@ -42,11 +43,11 @@ options = CreateUIResourceOptions(
42
43
 
43
44
  resource = create_ui_resource(options)
44
45
  print(resource)
45
- \`\`\`
46
+ ```
46
47
 
47
48
  **Output:**
48
49
 
49
- \`\`\`json
50
+ ```json
50
51
  {
51
52
  "type": "resource",
52
53
  "resource": {
@@ -57,11 +58,11 @@ print(resource)
57
58
  "_meta": null
58
59
  }
59
60
  }
60
- \`\`\`
61
+ ```
61
62
 
62
63
  #### External URL (iframe)
63
64
 
64
- \`\`\`python
65
+ ```python
65
66
  from mcp_ui import ExternalUrlContent, CreateUIResourceOptions, create_ui_resource
66
67
 
67
68
  options = CreateUIResourceOptions(
@@ -71,11 +72,11 @@ options = CreateUIResourceOptions(
71
72
  )
72
73
 
73
74
  iframe_res = create_ui_resource(options)
74
- \`\`\`
75
+ ```
75
76
 
76
77
  **Output:**
77
78
 
78
- \`\`\`json
79
+ ```json
79
80
  {
80
81
  "type": "resource",
81
82
  "resource": {
@@ -86,11 +87,11 @@ iframe_res = create_ui_resource(options)
86
87
  "_meta": null
87
88
  }
88
89
  }
89
- \`\`\`
90
+ ```
90
91
 
91
92
  #### Remote DOM (React)
92
93
 
93
- \`\`\`python
94
+ ```python
94
95
  from mcp_ui import RemoteDomContent, CreateUIResourceOptions, create_ui_resource
95
96
 
96
97
  options = CreateUIResourceOptions(
@@ -100,11 +101,11 @@ options = CreateUIResourceOptions(
100
101
  )
101
102
 
102
103
  remote_res = create_ui_resource(options)
103
- \`\`\`
104
+ ```
104
105
 
105
106
  **Output (blob is Base64-encoded):**
106
107
 
107
- \`\`\`json
108
+ ```json
108
109
  {
109
110
  "type": "resource",
110
111
  "resource": {
@@ -115,7 +116,7 @@ remote_res = create_ui_resource(options)
115
116
  "_meta": null
116
117
  }
117
118
  }
118
- \`\`\`
119
+ ```
119
120
 
120
121
  ---
121
122
 
@@ -123,7 +124,7 @@ remote_res = create_ui_resource(options)
123
124
 
124
125
  You can attach metadata to resources. Keys are automatically prefixed with \`mcpui.dev/ui-\`.
125
126
 
126
- \`\`\`python
127
+ ```python
127
128
  options = CreateUIResourceOptions(
128
129
  uri="ui://demo/meta",
129
130
  content=RawHtmlContent(type="rawHtml", htmlString="<p>Meta Example</p>"),
@@ -132,11 +133,11 @@ options = CreateUIResourceOptions(
132
133
  )
133
134
 
134
135
  meta_res = create_ui_resource(options)
135
- \`\`\`
136
+ ```
136
137
 
137
- **Output includes \`_meta\`:**
138
+ **Output includes \`\_meta\`:**
138
139
 
139
- \`\`\`json
140
+ ```json
140
141
  {
141
142
  "type": "resource",
142
143
  "resource": {
@@ -149,7 +150,7 @@ meta_res = create_ui_resource(options)
149
150
  }
150
151
  }
151
152
  }
152
- \`\`\`
153
+ ```
153
154
 
154
155
  ---
155
156
 
@@ -157,14 +158,14 @@ meta_res = create_ui_resource(options)
157
158
 
158
159
  #### Tool Call
159
160
 
160
- \`\`\`python
161
+ ```python
161
162
  from mcp_ui import ui_action_result_tool_call
162
163
  action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
163
- \`\`\`
164
+ ```
164
165
 
165
166
  **Output:**
166
167
 
167
- \`\`\`json
168
+ ```json
168
169
  {
169
170
  "type": "tool",
170
171
  "payload": {
@@ -172,50 +173,50 @@ action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
172
173
  "params": { "query": "MCP SDK" }
173
174
  }
174
175
  }
175
- \`\`\`
176
+ ```
176
177
 
177
178
  #### Prompt
178
179
 
179
- \`\`\`python
180
+ ```python
180
181
  from mcp_ui import ui_action_result_prompt
181
182
  action = ui_action_result_prompt("Please confirm your choice")
182
- \`\`\`
183
+ ```
183
184
 
184
185
  **Output:**
185
186
 
186
- \`\`\`json
187
+ ```json
187
188
  {
188
189
  "type": "prompt",
189
190
  "payload": { "prompt": "Please confirm your choice" }
190
191
  }
191
- \`\`\`
192
+ ```
192
193
 
193
194
  #### Link
194
195
 
195
- \`\`\`python
196
+ ```python
196
197
  from mcp_ui import ui_action_result_link
197
198
  action = ui_action_result_link("https://example.com")
198
- \`\`\`
199
+ ```
199
200
 
200
201
  **Output:**
201
202
 
202
- \`\`\`json
203
+ ```json
203
204
  {
204
205
  "type": "link",
205
206
  "payload": { "url": "https://example.com" }
206
207
  }
207
- \`\`\`
208
+ ```
208
209
 
209
210
  #### Intent
210
211
 
211
- \`\`\`python
212
+ ```python
212
213
  from mcp_ui import ui_action_result_intent
213
214
  action = ui_action_result_intent("share", {"platform": "twitter"})
214
- \`\`\`
215
+ ```
215
216
 
216
217
  **Output:**
217
218
 
218
- \`\`\`json
219
+ ```json
219
220
  {
220
221
  "type": "intent",
221
222
  "payload": {
@@ -223,40 +224,43 @@ action = ui_action_result_intent("share", {"platform": "twitter"})
223
224
  "params": { "platform": "twitter" }
224
225
  }
225
226
  }
226
- \`\`\`
227
+ ```
227
228
 
228
229
  #### Notification
229
230
 
230
- \`\`\`python
231
+ ```python
231
232
  from mcp_ui import ui_action_result_notification
232
233
  action = ui_action_result_notification("Saved successfully!")
233
- \`\`\`
234
+ ```
234
235
 
235
236
  **Output:**
236
237
 
237
- \`\`\`json
238
+ ```json
238
239
  {
239
240
  "type": "notify",
240
241
  "payload": { "message": "Saved successfully!" }
241
242
  }
242
- \`\`\`
243
+ ```
243
244
 
244
245
  ---
245
246
 
246
247
  ## 📖 API Reference
247
248
 
248
249
  ### create_ui_resource(options: CreateUIResourceOptions) → Dict[str, Any]
250
+
249
251
  Creates a UI resource for MCP. Returns a JSON-serializable dict.
250
252
 
251
253
  **Parameters:**
252
- - \`uri\`: must start with \`ui://\`
253
- - \`content\`: one of \`RawHtmlContent\`, \`ExternalUrlContent\`, \`RemoteDomContent\`
254
- - \`encoding\`: \`"text"\` or \`"blob"\`
255
- - \`uiMetadata\`: UI-specific metadata (auto-prefixed)
256
- - \`metadata\`: General metadata
257
- - \`resourceProps\`: Extra resource fields
254
+
255
+ - `uri`: must start with `ui://`
256
+ - `content`: one of `RawHtmlContent`, `ExternalUrlContent`, `RemoteDomContent`
257
+ - `encoding`: `"text"` or `"blob"`
258
+ - `uiMetadata`: UI-specific metadata (auto-prefixed)
259
+ - `metadata`: General metadata
260
+ - `resourceProps`: Extra resource fields
258
261
 
259
262
  **Type System:**
263
+
260
264
  - **Content payloads**:
261
265
  - RawHtmlContent(htmlString)
262
266
  - ExternalUrlContent(iframeUrl)
@@ -272,11 +276,11 @@ Creates a UI resource for MCP. Returns a JSON-serializable dict.
272
276
  ## ⚙️ Notes
273
277
 
274
278
  - Internally uses dataclasses for type safety, but always returns dicts (via \`asdict()\`) for MCP compatibility.
275
- - Enforces URI format (\`ui://\` prefix).
279
+ - Enforces URI format (`ui://` prefix).
276
280
  - Auto-encodes blob resources in Base64.
277
281
 
278
282
  ---
279
283
 
280
284
  ## 📄 License
281
285
 
282
- MIT – same as the original MCP-UI SDK.
286
+ MIT – Similar to the original MCP-UI Typescript server SDK.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-ui"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "A Python SDK for building MCP UI resources (iframe, panels, text blocks, etc.) in a type-safe way."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes