Skip to content

Commit d80d37b

Browse files
authored
Merge pull request #6 from syncable-dev/feature/pub-creates
Feature/pub creates
2 parents ee91645 + 55ceffb commit d80d37b

6 files changed

Lines changed: 41 additions & 70 deletions

File tree

mcp-python-server-client/src/mcp_py_client_rust_server_sse.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,43 @@
11
import asyncio
2+
import json
23
from mcp.client.session import ClientSession
3-
# Import the sse_client instead of stdio_client
44
from mcp.client.sse import sse_client
5+
from .utils import render_utility_result
56

6-
# Instructions:
7-
# 1. Start the Rust SSE server in a separate terminal:
8-
# cargo run --release --bin mcp-rust-server (or whatever your SSE binary is named)
9-
# 2. Run this Python script.
7+
# to start the server, run:
8+
# cargo run --release --bin mcp-sse
109

1110
async def main():
1211
# The URL where the Rust SSE server is listening.
13-
# The sse_client requires the full endpoint, which is typically /mcp.
14-
server_url = "http://127.0.0.1:8001/sse"
12+
server_url = "http://127.0.0.1:8000/sse"
1513

16-
# Use the sse_client context manager with the server URL
1714
async with sse_client(server_url) as (read, write):
1815
async with ClientSession(read, write) as session:
1916
await session.initialize()
2017

2118
# List available tools
2219
tools = await session.list_tools()
23-
24-
print("Tools:", tools)
25-
26-
# Call the 'add' tool
27-
add_result = await session.call_tool("add", {"a": 2, "b": 3})
28-
print("Add result:", add_result)
29-
30-
# Call the 'multiply' tool
31-
multiply_result = await session.call_tool("multiply", {"a": 4, "b": 5})
32-
print("Multiply result:", multiply_result)
33-
34-
# Call the 'reverse' tool
35-
reverse_result = await session.call_tool("reverse", {"text": "hello"})
36-
print("Reverse result:", reverse_result)
37-
38-
# Calling the tools we created to mimic resources and prompts
39-
about_result = await session.call_tool("about_info", {})
40-
print("About Info result:", about_result)
41-
42-
greeting_result = await session.call_tool("greeting", {"name": "Alice"})
43-
print("Greeting result:", greeting_result)
44-
45-
summary_result = await session.call_tool("summarize", {"text": "This is a long text that should be summarized."})
46-
print("Summary result:", summary_result)
20+
print("Tools:")
21+
render_utility_result(tools)
22+
23+
# Call the 'about info' tool
24+
about_info_result = await session.call_tool("about_info", {})
25+
print("About info result:")
26+
render_utility_result(about_info_result)
27+
28+
code_analyze_result = await session.call_tool("analysis_scan", {"path": "../", "display": "matrix"})
29+
print("Code analysis result:")
30+
render_utility_result(code_analyze_result)
31+
32+
# Call the 'security scan' tool
33+
security_scan_result = await session.call_tool("security_scan", {"path": "../"})
34+
print("Security scan result:")
35+
render_utility_result(security_scan_result)
36+
37+
# Call the 'dependency scan' tool
38+
dependency_scan_result = await session.call_tool("dependency_scan", {"path": "../"})
39+
print("Dependency scan result:")
40+
render_utility_result(dependency_scan_result)
4741

4842

4943
if __name__ == "__main__":

mcp-python-server-client/src/mcp_py_client_rust_server_stdio.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,22 @@
22
import json
33
from mcp.client.session import ClientSession
44
from mcp.client.stdio import StdioServerParameters, stdio_client
5-
from pprint import pprint
5+
from .utils import render_utility_result
66

77
# to start the server, run:
88
# from cpr-rust-server folder cargo run --release
99

10-
def render_utility_result(result):
11-
"""
12-
Parses and prints the formatted result from a tool.
13-
It can handle both raw formatted strings (with ANSI codes) and
14-
JSON-encoded strings containing a formatted report.
15-
"""
16-
if not result or not result.content or result.isError:
17-
print("Invalid or error result.")
18-
pprint(result)
19-
return
20-
21-
try:
22-
# The result is a single TextContent object
23-
text_content = result.content[0].text
24-
25-
try:
26-
# First, try to load as JSON. This handles tool outputs that
27-
# are JSON-encoded strings (e.g., a report string inside a JSON string).
28-
report_string = json.loads(text_content)
29-
print(report_string)
30-
except json.JSONDecodeError:
31-
# If JSON decoding fails, assume it's a raw, pre-formatted string
32-
# (like the output from the 'about_info' tool with ANSI codes).
33-
print(text_content)
34-
35-
except (IndexError, AttributeError) as e:
36-
print(f"Error parsing result: {e}")
37-
print("Printing raw result instead:")
38-
pprint(result)
39-
40-
4110
async def main():
4211
async with stdio_client(
43-
StdioServerParameters(command="../mcp-rust-server/target/release/mcp-stdio")
12+
StdioServerParameters(command="../rust-mcp-server-syncable-cli/target/release/mcp-stdio")
4413
) as (read, write):
4514
async with ClientSession(read, write) as session:
4615
await session.initialize()
4716

4817
# List available tools
4918
tools = await session.list_tools()
5019
print("Tools:")
51-
pprint(tools)
20+
render_utility_result(tools)
5221

5322
# Call the 'about info' tool
5423
about_info_result = await session.call_tool("about_info", {})

release-plz.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[workspace]
2+
packages = ["rust-mcp-server-syncable-cli"]
3+
4+
[release-plz]
5+
manifest_path = "rust-mcp-server-syncable-cli/Cargo.toml"
6+
7+
[changelog]
8+
path = "rust-mcp-server-syncable-cli/CHANGELOG.md"

rust-mcp-server-syncable-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "mcp-rust-server"
2+
name = "rust-mcp-server-syncable-cli"
33
version = "0.1.0"
44
edition = "2021"
55
authors = [
@@ -10,7 +10,7 @@ description = "High-performance Model Context Protocol (MCP) server for code ana
1010
license = "MIT"
1111
repository = "https://github.com/syncable-dev/syncable-cli-mcp-server"
1212
homepage = "https://github.com/syncable-dev/syncable-cli-mcp-server"
13-
documentation = "https://docs.rs/mcp-rust-server"
13+
documentation = "https://docs.rs/rust-mcp-server-syncable-cli"
1414
readme = "README.md"
1515

1616
# crates.io discoverability

rust-mcp-server-syncable-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// src/main.rs
2-
use mcp_rust_server::start_stdio;
2+
use rust_mcp_server_syncable_cli::start_stdio;
33

44
#[tokio::main]
55
async fn main() -> Result<(), Box<dyn std::error::Error>> {

rust-mcp-server-syncable-cli/src/main_sse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// src/main_sse.rs
2-
use mcp_rust_server::start_sse;
2+
use rust_mcp_server_syncable_cli::start_sse;
33

44
#[tokio::main]
55
async fn main() -> Result<(), Box<dyn std::error::Error>> {

0 commit comments

Comments
 (0)