@@ -8,10 +8,10 @@ Start the server using either stdio (default) or SSE transport:
8
8
9
9
``` bash
10
10
# Using stdio transport (default)
11
- mcp-simple-prompt
11
+ uv mcp-simple-prompt
12
12
13
13
# Using SSE transport on custom port
14
- mcp-simple-prompt --transport sse --port 8000
14
+ uv run mcp-simple-prompt --transport sse --port 8000
15
15
```
16
16
17
17
The server exposes a prompt named "simple" that accepts two optional arguments:
@@ -21,22 +21,35 @@ The server exposes a prompt named "simple" that accepts two optional arguments:
21
21
22
22
## Example
23
23
24
- Using the MCP client, you can retrieve the prompt like this:
24
+ Using the MCP client, you can retrieve the prompt like this using the STDIO transport :
25
25
26
26
``` python
27
- from mcp.client import ClientSession
28
-
29
- async with ClientSession() as session:
30
- await session.initialize()
31
-
32
- # List available prompts
33
- prompts = await session.list_prompts()
34
- print (prompts)
35
-
36
- # Get the prompt with arguments
37
- prompt = await session.get_prompt(" simple" , {
38
- " context" : " User is a software developer" ,
39
- " topic" : " Python async programming"
40
- })
41
- print (prompt)
27
+ import asyncio
28
+ from mcp.client.session import ClientSession
29
+ from mcp.client.stdio import StdioServerParameters, stdio_client
30
+
31
+
32
+ async def main ():
33
+ async with stdio_client(
34
+ StdioServerParameters(command = " uv" , args = [" run" , " mcp-simple-prompt" ])
35
+ ) as (read, write):
36
+ async with ClientSession(read, write) as session:
37
+ await session.initialize()
38
+
39
+ # List available prompts
40
+ prompts = await session.list_prompts()
41
+ print (prompts)
42
+
43
+ # Get the prompt with arguments
44
+ prompt = await session.get_prompt(
45
+ " simple" ,
46
+ {
47
+ " context" : " User is a software developer" ,
48
+ " topic" : " Python async programming" ,
49
+ },
50
+ )
51
+ print (prompt)
52
+
53
+
54
+ asyncio.run(main())
42
55
```
0 commit comments