mcp-ui 0.1.0__tar.gz → 0.1.2__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.2
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
@@ -14,7 +14,6 @@ Classifier: Development Status :: 3 - Alpha
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Operating System :: OS Independent
16
16
  Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.8
18
17
  Classifier: Programming Language :: Python :: 3.9
19
18
  Classifier: Programming Language :: Python :: 3.10
20
19
  Classifier: Programming Language :: Python :: 3.11
@@ -22,29 +21,30 @@ Classifier: Programming Language :: Python :: 3.12
22
21
  Requires-Python: >=3.9
23
22
  Description-Content-Type: text/markdown
24
23
 
25
-
26
24
  # MCP-UI Python SDK
27
25
 
28
26
  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.
27
+ 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
28
 
31
29
  ---
32
30
 
33
31
  ## 📦 Installation
34
32
 
35
- \`\`\`bash
33
+ ```bash
36
34
  pip install mcp-ui
37
- \`\`\`
35
+ ```
38
36
 
39
37
  ---
40
38
 
41
39
  ## 🚀 Core Concepts
42
40
 
43
41
  ### What is a UI Resource?
42
+
44
43
  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
44
  This SDK helps you create them consistently with correct metadata and encodings.
46
45
 
47
46
  ### What is a UI Action?
47
+
48
48
  A **UI action result** represents an action the MCP client should take (e.g., open a link, show a prompt, call a tool).
49
49
 
50
50
  ---
@@ -55,7 +55,7 @@ A **UI action result** represents an action the MCP client should take (e.g., op
55
55
 
56
56
  #### Raw HTML
57
57
 
58
- \`\`\`python
58
+ ```python
59
59
  from mcp_ui import RawHtmlContent, CreateUIResourceOptions, create_ui_resource
60
60
 
61
61
  options = CreateUIResourceOptions(
@@ -66,11 +66,11 @@ options = CreateUIResourceOptions(
66
66
 
67
67
  resource = create_ui_resource(options)
68
68
  print(resource)
69
- \`\`\`
69
+ ```
70
70
 
71
71
  **Output:**
72
72
 
73
- \`\`\`json
73
+ ```json
74
74
  {
75
75
  "type": "resource",
76
76
  "resource": {
@@ -81,11 +81,11 @@ print(resource)
81
81
  "_meta": null
82
82
  }
83
83
  }
84
- \`\`\`
84
+ ```
85
85
 
86
86
  #### External URL (iframe)
87
87
 
88
- \`\`\`python
88
+ ```python
89
89
  from mcp_ui import ExternalUrlContent, CreateUIResourceOptions, create_ui_resource
90
90
 
91
91
  options = CreateUIResourceOptions(
@@ -95,11 +95,11 @@ options = CreateUIResourceOptions(
95
95
  )
96
96
 
97
97
  iframe_res = create_ui_resource(options)
98
- \`\`\`
98
+ ```
99
99
 
100
100
  **Output:**
101
101
 
102
- \`\`\`json
102
+ ```json
103
103
  {
104
104
  "type": "resource",
105
105
  "resource": {
@@ -110,11 +110,11 @@ iframe_res = create_ui_resource(options)
110
110
  "_meta": null
111
111
  }
112
112
  }
113
- \`\`\`
113
+ ```
114
114
 
115
115
  #### Remote DOM (React)
116
116
 
117
- \`\`\`python
117
+ ```python
118
118
  from mcp_ui import RemoteDomContent, CreateUIResourceOptions, create_ui_resource
119
119
 
120
120
  options = CreateUIResourceOptions(
@@ -124,11 +124,11 @@ options = CreateUIResourceOptions(
124
124
  )
125
125
 
126
126
  remote_res = create_ui_resource(options)
127
- \`\`\`
127
+ ```
128
128
 
129
129
  **Output (blob is Base64-encoded):**
130
130
 
131
- \`\`\`json
131
+ ```json
132
132
  {
133
133
  "type": "resource",
134
134
  "resource": {
@@ -139,7 +139,7 @@ remote_res = create_ui_resource(options)
139
139
  "_meta": null
140
140
  }
141
141
  }
142
- \`\`\`
142
+ ```
143
143
 
144
144
  ---
145
145
 
@@ -147,7 +147,7 @@ remote_res = create_ui_resource(options)
147
147
 
148
148
  You can attach metadata to resources. Keys are automatically prefixed with \`mcpui.dev/ui-\`.
149
149
 
150
- \`\`\`python
150
+ ```python
151
151
  options = CreateUIResourceOptions(
152
152
  uri="ui://demo/meta",
153
153
  content=RawHtmlContent(type="rawHtml", htmlString="<p>Meta Example</p>"),
@@ -156,11 +156,11 @@ options = CreateUIResourceOptions(
156
156
  )
157
157
 
158
158
  meta_res = create_ui_resource(options)
159
- \`\`\`
159
+ ```
160
160
 
161
- **Output includes \`_meta\`:**
161
+ **Output includes \`\_meta\`:**
162
162
 
163
- \`\`\`json
163
+ ```json
164
164
  {
165
165
  "type": "resource",
166
166
  "resource": {
@@ -173,7 +173,7 @@ meta_res = create_ui_resource(options)
173
173
  }
174
174
  }
175
175
  }
176
- \`\`\`
176
+ ```
177
177
 
178
178
  ---
179
179
 
@@ -181,14 +181,14 @@ meta_res = create_ui_resource(options)
181
181
 
182
182
  #### Tool Call
183
183
 
184
- \`\`\`python
184
+ ```python
185
185
  from mcp_ui import ui_action_result_tool_call
186
186
  action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
187
- \`\`\`
187
+ ```
188
188
 
189
189
  **Output:**
190
190
 
191
- \`\`\`json
191
+ ```json
192
192
  {
193
193
  "type": "tool",
194
194
  "payload": {
@@ -196,50 +196,50 @@ action = ui_action_result_tool_call("searchTool", {"query": "MCP SDK"})
196
196
  "params": { "query": "MCP SDK" }
197
197
  }
198
198
  }
199
- \`\`\`
199
+ ```
200
200
 
201
201
  #### Prompt
202
202
 
203
- \`\`\`python
203
+ ```python
204
204
  from mcp_ui import ui_action_result_prompt
205
205
  action = ui_action_result_prompt("Please confirm your choice")
206
- \`\`\`
206
+ ```
207
207
 
208
208
  **Output:**
209
209
 
210
- \`\`\`json
210
+ ```json
211
211
  {
212
212
  "type": "prompt",
213
213
  "payload": { "prompt": "Please confirm your choice" }
214
214
  }
215
- \`\`\`
215
+ ```
216
216
 
217
217
  #### Link
218
218
 
219
- \`\`\`python
219
+ ```python
220
220
  from mcp_ui import ui_action_result_link
221
221
  action = ui_action_result_link("https://example.com")
222
- \`\`\`
222
+ ```
223
223
 
224
224
  **Output:**
225
225
 
226
- \`\`\`json
226
+ ```json
227
227
  {
228
228
  "type": "link",
229
229
  "payload": { "url": "https://example.com" }
230
230
  }
231
- \`\`\`
231
+ ```
232
232
 
233
233
  #### Intent
234
234
 
235
- \`\`\`python
235
+ ```python
236
236
  from mcp_ui import ui_action_result_intent
237
237
  action = ui_action_result_intent("share", {"platform": "twitter"})
238
- \`\`\`
238
+ ```
239
239
 
240
240
  **Output:**
241
241
 
242
- \`\`\`json
242
+ ```json
243
243
  {
244
244
  "type": "intent",
245
245
  "payload": {
@@ -247,40 +247,43 @@ action = ui_action_result_intent("share", {"platform": "twitter"})
247
247
  "params": { "platform": "twitter" }
248
248
  }
249
249
  }
250
- \`\`\`
250
+ ```
251
251
 
252
252
  #### Notification
253
253
 
254
- \`\`\`python
254
+ ```python
255
255
  from mcp_ui import ui_action_result_notification
256
256
  action = ui_action_result_notification("Saved successfully!")
257
- \`\`\`
257
+ ```
258
258
 
259
259
  **Output:**
260
260
 
261
- \`\`\`json
261
+ ```json
262
262
  {
263
263
  "type": "notify",
264
264
  "payload": { "message": "Saved successfully!" }
265
265
  }
266
- \`\`\`
266
+ ```
267
267
 
268
268
  ---
269
269
 
270
270
  ## 📖 API Reference
271
271
 
272
272
  ### create_ui_resource(options: CreateUIResourceOptions) → Dict[str, Any]
273
+
273
274
  Creates a UI resource for MCP. Returns a JSON-serializable dict.
274
275
 
275
276
  **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
277
+
278
+ - `uri`: must start with `ui://`
279
+ - `content`: one of `RawHtmlContent`, `ExternalUrlContent`, `RemoteDomContent`
280
+ - `encoding`: `"text"` or `"blob"`
281
+ - `uiMetadata`: UI-specific metadata (auto-prefixed)
282
+ - `metadata`: General metadata
283
+ - `resourceProps`: Extra resource fields
282
284
 
283
285
  **Type System:**
286
+
284
287
  - **Content payloads**:
285
288
  - RawHtmlContent(htmlString)
286
289
  - ExternalUrlContent(iframeUrl)
@@ -296,11 +299,11 @@ Creates a UI resource for MCP. Returns a JSON-serializable dict.
296
299
  ## ⚙️ Notes
297
300
 
298
301
  - Internally uses dataclasses for type safety, but always returns dicts (via \`asdict()\`) for MCP compatibility.
299
- - Enforces URI format (\`ui://\` prefix).
302
+ - Enforces URI format (`ui://` prefix).
300
303
  - Auto-encodes blob resources in Base64.
301
304
 
302
305
  ---
303
306
 
304
307
  ## 📄 License
305
308
 
306
- MIT – same as the original MCP-UI SDK.
309
+ 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.2"
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" }
@@ -11,7 +11,6 @@ keywords = ["mcp", "ui", "sdk", "python", "iframe", "chat", "agents"]
11
11
  classifiers = [
12
12
  "Development Status :: 3 - Alpha",
13
13
  "Programming Language :: Python :: 3",
14
- "Programming Language :: Python :: 3.8",
15
14
  "Programming Language :: Python :: 3.9",
16
15
  "Programming Language :: Python :: 3.10",
17
16
  "Programming Language :: Python :: 3.11",
@@ -33,7 +32,6 @@ Documentation = "https://github.com/jameszokah/mcp-ui#readme"
33
32
  requires = ["hatchling"]
34
33
  build-backend = "hatchling.build"
35
34
 
36
- # ✅ Tell Hatchling to include the package inside `src/mcp_ui`
37
35
  [tool.hatch.build.targets.wheel]
38
36
  packages = ["src/mcp_ui"]
39
37
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes