Skip to content

Commit bf24b71

Browse files
dcodesdevjonaro00
andauthored
feat(mcp, cargo-shuttle): The Shuttle MCP Server (#2074)
* mcp init * refactor * stdio fix * deploy * cwd * deployment * logs and project related commands * resources and certificates commands * mcp rename * mcp installation guide * packages fixed * removed commands * delete todo file * readme update * search docs tool added * cwd * execute_command cwd * check version * deployment refactored * tools refactored * Version checking * Constants * mcp patch * fixes MCP server arguments for some tools * constants updated * readme updated * docs * docs updated version updated * constants fixed * version checks * version set to 0.55.0 * README.md updated * mcp dir moved to cargo-shuttle * mcp code moved to shuttle cli * features added for rmcp * removed main.rs * removed mcp server crate * upgrade shuttle command updated * removed version checking in the mcp server * mcp library crate * removed mcp/ dir in cargo-shuttle * moved mcp code to a library crate * removed toml dependency * shuttle-mcp crate version -> 0.55.0 * removed unnecessary mcp tools * reduced commands/args * linter error fixed * added `id` arg for some mcp tools * deployment list removed args * MCP server subcommand changed * nits, fix argument lists * simplify execute_command * nit: Cargo.toml * ci: add release job --------- Co-authored-by: jonaro00 <[email protected]>
1 parent 03fa327 commit bf24b71

File tree

16 files changed

+561
-1
lines changed

16 files changed

+561
-1
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ workflows:
497497
parameters:
498498
path:
499499
- common
500+
- mcp
500501
name: publish-<< matrix.path >>
501502
requires:
502503
- approve-publish-crates

Cargo.lock

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"codegen",
88
"common",
99
"ifc",
10+
"mcp",
1011
"runtime",
1112
"service",
1213
]
@@ -23,6 +24,7 @@ shuttle-api-client = { path = "api-client", version = "0.55.0", default-features
2324
shuttle-codegen = { path = "codegen", version = "0.55.0" }
2425
shuttle-common = { path = "common", version = "0.55.0" }
2526
shuttle-ifc = { path = "ifc", version = "0.55.0" }
27+
shuttle-mcp = { path = "mcp", version = "0.55.0" }
2628
shuttle-service = { path = "service", version = "0.55.0" }
2729

2830
anyhow = "1.0.66"
@@ -66,6 +68,7 @@ reqwest = { version = "0.12.14", default-features = false, features = [
6668
] }
6769
reqwest-middleware = "0.4.0"
6870
rexpect = "0.6.0"
71+
rmcp = { version = "0.1.5", features = ["server", "transport-io"] }
6972
semver = { version = "1.0.17", features = ["serde"] }
7073
serde = { version = "1.0.148", default-features = false }
7174
serde_json = "1.0.89"
@@ -89,6 +92,7 @@ trybuild = "1.0.72"
8992
typeshare = "1.0.3"
9093
utoipa = "5"
9194
url = "2.5.4"
95+
urlencoding = "2.1.3"
9296
walkdir = "2.3.3"
9397
webbrowser = "1.0.1"
9498
zeroize = "1.6.0"

cargo-shuttle/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ default-run = "shuttle"
1212
shuttle-api-client = { workspace = true, default-features = true }
1313
shuttle-common = { workspace = true, features = ["models", "tables", "config"] }
1414
shuttle-ifc = { workspace = true }
15+
shuttle-mcp = { workspace = true }
1516

1617
anyhow = { workspace = true }
1718
async-trait = { workspace = true }

cargo-shuttle/src/args.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ pub enum Command {
161161
#[arg(long)]
162162
preview: bool,
163163
},
164+
/// Commands for the Shuttle MCP server
165+
#[command(subcommand)]
166+
Mcp(McpCommand),
167+
}
168+
169+
#[derive(Subcommand)]
170+
pub enum McpCommand {
171+
/// Start the Shuttle MCP server
172+
Start,
164173
}
165174

166175
#[derive(Subcommand)]

cargo-shuttle/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use zip::write::FileOptions;
5858

5959
use crate::args::{
6060
CertificateCommand, ConfirmationArgs, DeployArgs, DeploymentCommand, GenerateCommand, InitArgs,
61-
LoginArgs, LogoutArgs, LogsArgs, OutputMode, ProjectCommand, ProjectUpdateCommand,
61+
LoginArgs, LogoutArgs, LogsArgs, McpCommand, OutputMode, ProjectCommand, ProjectUpdateCommand,
6262
ResourceCommand, SecretsArgs, TableArgs, TemplateLocation,
6363
};
6464
pub use crate::args::{Command, ProjectArgs, RunArgs, ShuttleArgs};
@@ -301,6 +301,9 @@ impl Shuttle {
301301
ProjectCommand::Link => Ok(()), // logic is done in `load_project` in previous step
302302
},
303303
Command::Upgrade { preview } => update_cargo_shuttle(preview).await,
304+
Command::Mcp(cmd) => match cmd {
305+
McpCommand::Start => shuttle_mcp::run_mcp_server().await,
306+
},
304307
}
305308
}
306309

mcp/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "shuttle-mcp"
3+
version = "0.55.0"
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
7+
8+
[dependencies]
9+
anyhow = { workspace = true }
10+
reqwest = { workspace = true, features = ["json"] }
11+
rmcp = { workspace = true, features = ["server", "transport-io"] }
12+
serde = { workspace = true }
13+
tokio = { workspace = true, features = ["full"] }
14+
urlencoding = { workspace = true }

mcp/src/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub const SHUTTLE_DOCS_SEARCH_BASE_URL: &str =
2+
"https://09ga7allme.execute-api.eu-west-2.amazonaws.com/prod";

mcp/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use rmcp::{transport::stdio, ServiceExt};
2+
3+
use crate::mcp::ShuttleMcpServer;
4+
5+
mod constants;
6+
mod mcp;
7+
mod tools;
8+
mod utils;
9+
10+
pub async fn run_mcp_server() -> Result<(), anyhow::Error> {
11+
let service = ShuttleMcpServer.serve(stdio()).await?;
12+
service.waiting().await?;
13+
Ok(())
14+
}

0 commit comments

Comments
 (0)