Skip to content

Commit d93f515

Browse files
committed
initial command
1 parent 1a1ae59 commit d93f515

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ description = "The Posit Connect command-line interface."
55
authors = [{ name = "Posit, PBC", email = "[email protected]" }]
66
license = { file = "LICENSE.md" }
77
readme = { file = "README.md", content-type = "text/markdown" }
8-
requires-python = ">=3.8"
8+
requires-python = ">=3.10"
99

1010
dependencies = [
1111
"typing-extensions>=4.8.0",
1212
"pip>=10.0.0",
1313
"semver>=2.0.0,<4.0.0",
1414
"pyjwt>=2.4.0",
1515
"click>=8.0.0",
16-
"toml>=0.10; python_version < '3.11'"
16+
"toml>=0.10; python_version < '3.11'",
17+
"fastmcp",
18+
"posit-sdk"
1719
]
1820

1921
dynamic = ["version"]

rsconnect/main.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,29 @@ def version():
392392
click.echo(VERSION)
393393

394394

395+
@cli.command(help="Start the MCP server")
396+
@click.option("--server", "-s", default="http://localhost:3939", help="Posit Connect server URL")
397+
@click.option(
398+
"--api-key", "-k", envvar="CONNECT_API_KEY", help="The API key to use to authenticate with Posit Connect."
399+
)
400+
def mcp_server(server: str, api_key: str):
401+
from fastmcp import Context, FastMCP
402+
from posit.connect import Client
403+
404+
def get_content_logs(ctx: Context, app_guid: str):
405+
client = Client(server, api_key)
406+
first_job = list(client.content.get(app_guid).jobs.fetch())[0]
407+
key = first_job["key"]
408+
logs = client.get(f"v1/content/{app_guid}/jobs/{key}/log")
409+
return logs.json()
410+
411+
mcp = FastMCP("Connect MCP")
412+
413+
mcp.tool(description="Get content logs from Posit Connect")(get_content_logs)
414+
415+
mcp.run()
416+
417+
395418
def _test_server_and_api(server: str, api_key: str, insecure: bool, ca_cert: str | None):
396419
"""
397420
Test the specified server information to make sure it works. If so, a

0 commit comments

Comments
 (0)