Skip to content

Commit bda7b44

Browse files
authored
docs: improve Python docs (#114)
1 parent 15f1c11 commit bda7b44

4 files changed

Lines changed: 81 additions & 5 deletions

File tree

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<a href="https://www.npmjs.com/package/@mcp-ui/server"><img src="https://img.shields.io/npm/v/@mcp-ui/server?label=server&color=green" alt="Server Version"></a>
99
<a href="https://www.npmjs.com/package/@mcp-ui/client"><img src="https://img.shields.io/npm/v/@mcp-ui/client?label=client&color=blue" alt="Client Version"></a>
1010
<a href="https://rubygems.org/gems/mcp_ui_server"><img src="https://img.shields.io/gem/v/mcp_ui_server" alt="Ruby Server SDK Version"></a>
11+
<a href="https://pypi.org/project/mcp-ui-server/"><img src="https://img.shields.io/pypi/v/mcp-ui-server?label=python&color=yellow" alt="Python Server SDK Version"></a>
1112
<a href="https://discord.gg/CEAG4KW7ZH"><img src="https://img.shields.io/discord/1401195140436983879?logo=discord&label=discord" alt="Discord"></a>
1213
<a href="https://gitmcp.io/idosal/mcp-ui"><img src="https://img.shields.io/endpoint?url=https://gitmcp.io/badge/idosal/mcp-ui" alt="MCP Documentation"></a>
1314
</p>
@@ -43,6 +44,7 @@
4344
* **`@mcp-ui/server` (TypeScript)**: Utilities to generate UI resources (`UIResource`) on your MCP server.
4445
* **`@mcp-ui/client` (TypeScript)**: UI components (e.g., `<UIResourceRenderer />`) to render the UI resources and handle their events.
4546
* **`mcp_ui_server` (Ruby)**: Utilities to generate UI resources on your MCP server in a Ruby environment.
47+
* **`mcp-ui-server` (Python)**: Utilities to generate UI resources on your MCP server in a Python environment.
4648

4749
Together, they let you define reusable UI snippets on the server side, seamlessly and securely render them in the client, and react to their actions in the MCP host environment.
4850

@@ -162,6 +164,16 @@ yarn add @mcp-ui/server @mcp-ui/client
162164
gem install mcp_ui_server
163165
```
164166

167+
### Python
168+
169+
```bash
170+
# using pip
171+
pip install mcp-ui-server
172+
173+
# or uv
174+
uv add mcp-ui-server
175+
```
176+
165177
## 🚀 Getting Started
166178

167179
You can use [GitMCP](https://gitmcp.io/idosal/mcp-ui) to give your IDE access to `mcp-ui`'s latest documentation!
@@ -235,6 +247,28 @@ You can use [GitMCP](https://gitmcp.io/idosal/mcp-ui) to give your IDE access to
235247
}
236248
```
237249

250+
### Python
251+
252+
**Server-side**: Build your UI resources
253+
254+
```python
255+
from mcp_ui_server import create_ui_resource
256+
257+
# Inline HTML
258+
html_resource = create_ui_resource({
259+
"uri": "ui://greeting/1",
260+
"content": { "type": "rawHtml", "htmlString": "<p>Hello, from Python!</p>" },
261+
"encoding": "text",
262+
})
263+
264+
# External URL
265+
external_url_resource = create_ui_resource({
266+
"uri": "ui://greeting/2",
267+
"content": { "type": "externalUrl", "iframeUrl": "https://example.com" },
268+
"encoding": "text",
269+
})
270+
```
271+
238272
### Ruby
239273

240274
**Server-side**: Build your UI resources
@@ -281,6 +315,7 @@ For a detailed, simple, step-by-step guide on how to integrate `mcp-ui` into you
281315

282316
- **[TypeScript Server Walkthrough](https://mcpui.dev/guide/server/typescript/walkthrough)**
283317
- **[Ruby Server Walkthrough](https://mcpui.dev/guide/server/ruby/walkthrough)**
318+
- **[Python Server Walkthrough](https://mcpui.dev/guide/server/python/walkthrough)**
284319

285320
These guides will show you how to add a `mcp-ui` endpoint to an existing server, create tools that return UI resources, and test your setup with the `ui-inspector`!
286321

@@ -299,6 +334,7 @@ These guides will show you how to add a `mcp-ui` endpoint to an existing server,
299334
* **HTTP Streaming**: `https://remote-mcp-server-authless.idosalomon.workers.dev/mcp`
300335
* **SSE**: `https://remote-mcp-server-authless.idosalomon.workers.dev/sse`
301336
* **Ruby**: A barebones [demo server](/examples/ruby-server-demo) that shows how to use `mcp_ui_server` and `mcp` gems together.
337+
* **Python**: A simple [demo server](/examples/python-server-demo) that shows how to use the `mcp-ui-server` Python package.
302338

303339
Drop those URLs into any MCP-compatible host to see `mcp-ui` in action. For a supported local inspector, see the [ui-inspector](https://github.com/idosal/ui-inspector).
304340

docs/src/.vitepress/config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export default withMermaid(
4242
],
4343
['link', { rel: 'icon', type: 'image/png', href: '/logo.png' }],
4444
['link', { rel: 'icon', type: 'image/png', href: '/favicon.png' }],
45+
[
46+
'style',
47+
{},
48+
`.VPNavBar .VPNavBarSocialLinks a[href*="npmjs.com/package/@mcp-ui/server"] { border-left: 1px solid var(--vp-c-divider); margin-left: 8px; padding-left: 12px; }`
49+
],
4550
],
4651

4752
vite: {
@@ -81,6 +86,7 @@ export default withMermaid(
8186
link: '/guide/server/typescript/usage-examples',
8287
},
8388
{ text: 'Ruby', link: '/guide/server/ruby/usage-examples' },
89+
{ text: 'Python', link: '/guide/server/python/usage-examples' },
8490
],
8591
},
8692
{
@@ -110,6 +116,10 @@ export default withMermaid(
110116
text: 'mcp_ui_server Gem',
111117
link: 'https://rubygems.org/gems/mcp_ui_server',
112118
},
119+
{
120+
text: 'mcp-ui-server (PyPI)',
121+
link: 'https://pypi.org/project/mcp-ui-server/',
122+
},
113123
],
114124
},
115125
],
@@ -163,6 +173,15 @@ export default withMermaid(
163173
},
164174
],
165175
},
176+
{
177+
text: 'Python',
178+
collapsed: false,
179+
items: [
180+
{ text: 'Overview', link: '/guide/server/python/overview' },
181+
{ text: 'Walkthrough', link: '/guide/server/python/walkthrough' },
182+
{ text: 'Usage & Examples', link: '/guide/server/python/usage-examples' },
183+
],
184+
},
166185
],
167186
},
168187
{
@@ -245,6 +264,10 @@ export default withMermaid(
245264
},
246265
link: 'https://rubygems.org/gems/mcp_ui_server',
247266
},
267+
{
268+
icon: 'pypi',
269+
link: 'https://pypi.org/project/mcp-ui-server/',
270+
},
248271
],
249272

250273
footer: {

docs/src/.vitepress/theme/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
padding-bottom: 64px !important;
5555
}
5656

57+
.VPHome {
58+
margin-bottom: 16px !important;
59+
}
60+
5761
.VPHero .container {
5862
margin-top: 0 !important;
5963
}

docs/src/index.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ features:
2727
- title: ⚛️ Client SDK
2828
details: Provides a React component and Web Component for easy frontend integration. Render interactive UI resources and handle UI actions effortlessly.
2929
- title: 🛠️ Server SDKs
30-
details: Powerful utilities to construct interactive UI for MCP servers. Create HTML, React, Web Components, and external app UI with ergonomic APIs for Typescript and Ruby.
30+
details: Powerful utilities to construct interactive UI for MCP servers. Create HTML, React, Web Components, and external app UI with ergonomic APIs for TypeScript, Ruby, and Python.
3131
- title: 🔒 Secure
3232
details: All remote code executes in sandboxed iframes, ensuring host and user security while maintaining rich interactivity.
3333
- title: 🎨 Flexible
@@ -50,7 +50,7 @@ features:
5050

5151
**Server Side** - Create interactive resources to return in your MCP tool results:
5252

53-
::: code-group
53+
:::: code-group
5454
```typescript [TypeScript]
5555
import { createUIResource } from '@mcp-ui/server';
5656

@@ -64,6 +64,19 @@ const interactiveForm = createUIResource({
6464
});
6565
```
6666

67+
```python [Python]
68+
from mcp_ui_server import create_ui_resource
69+
70+
interactive_form = create_ui_resource({
71+
"uri": "ui://user-form/1",
72+
"content": {
73+
"type": "externalUrl",
74+
"iframeUrl": "https://yourapp.com"
75+
},
76+
"encoding": "text"
77+
})
78+
```
79+
6780
```ruby [Ruby]
6881
require 'mcp_ui_server'
6982

@@ -76,11 +89,11 @@ interactive_form = McpUiServer.create_ui_resource(
7689
encoding: :text
7790
)
7891
```
79-
:::
92+
::::
8093

8194
**Client Side** - Render on the host with a single component:
8295

83-
::: code-group
96+
:::: code-group
8497
```tsx [React]
8598
import { UIResourceRenderer } from '@mcp-ui/client';
8699

@@ -125,7 +138,7 @@ function MyApp({ mcpResource }) {
125138
});
126139
</script>
127140
```
128-
:::
141+
::::
129142

130143

131144
<style>

0 commit comments

Comments
 (0)