Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ and listed with their assets on the

### Added

- **devstack's MCP server for every folder.** The MCP upstreams page has a
setting per coding agent: devstack's MCP server per repository (as
before) or for you, in every folder. Then the hub writes one entry
`devstack` into the agent's own configuration (Claude Code, Codex,
Cursor), so its tools and the upstreams' are there in repositories
without a stack too, and takes it out when you switch back; the rest of
the file stays as it was (ADR-0100). A repository whose agent loads the
server twice, under two names, shows "MCP twice", and `devstack doctor`
says in any folder whether the server is registered there (#492).

- **The Skills page shows what happens for your agent.** A new tab, Flow,
draws the hooks of the skills switched on by when they give their text: a
session starts, a prompt matches, a lane stops, a session ends. Hovering a
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ thiserror = "2"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "net", "time", "signal", "io-util"] }
tokio-stream = { version = "0.1", features = ["sync"] }
toml = "1"
toml_edit = "0.25"
# The platform verifier: TLS to GitHub (update, release check) trusts the
# system's certificate store, so a TLS-inspecting proxy works as it does for
# the installers.
Expand Down
1 change: 1 addition & 0 deletions crates/devstack-hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tokio.workspace = true
tokio-rustls.workspace = true
tokio-stream.workspace = true
toml.workspace = true
toml_edit.workspace = true
ureq.workspace = true

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/devstack-hub/src/agentmcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ pub fn codex(config: &Path) -> Vec<Direct> {
.collect()
}

fn claude_file() -> Option<PathBuf> {
pub(crate) fn claude_file() -> Option<PathBuf> {
devstack_skills::agents::resolve(CLAUDE_FILE)
}

fn codex_file() -> Option<PathBuf> {
pub(crate) fn codex_file() -> Option<PathBuf> {
devstack_skills::agents::resolve(CODEX_FILE)
}

Expand Down
56 changes: 53 additions & 3 deletions crates/devstack-hub/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ pub mod agenthooks;
pub mod agentmcp;
mod branches;
mod guests;
mod mcp;
pub mod mcp;
mod mcpclient;
pub mod mcpscope;
mod notice;
mod notify;
mod open;
Expand Down Expand Up @@ -665,6 +666,7 @@ fn router(state: AppState) -> axum::Router {
.route("/hub/pool/skills/{name}", delete(pool::skill_remove))
.route("/hub/skills", get(poolskills::get))
.route("/hub/activity", get(activity_get))
.route("/hub/mcp/scope", get(mcp_scope_get).put(mcp_scope_put))
.route("/hub/activity/timeline", get(timeline_get))
.route(
"/hub/activity/transcripts",
Expand Down Expand Up @@ -1920,16 +1922,64 @@ async fn stack_mcp(State(s): State<AppState>, Path(id): Path<String>) -> Respons
let Some(e) = entry(&s, &id) else {
return err(StatusCode::NOT_FOUND, "no such stack");
};
match tokio::task::spawn_blocking(move || mcp::registered(&e.repo)).await {
Ok(files) => Json(serde_json::json!({
match tokio::task::spawn_blocking(move || (mcp::registered(&e.repo), mcp::doubles(&e.repo)))
.await
{
Ok((files, doubles)) => Json(serde_json::json!({
"registered": !files.is_empty(),
"files": files,
"doubles": doubles,
}))
.into_response(),
Err(e) => err(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()),
}
}

/// `GET /hub/mcp/scope`: where devstack's MCP server is registered for
/// each coding agent: per repository, or for the user in every folder
/// (#492).
async fn mcp_scope_get() -> Response {
match tokio::task::spawn_blocking(|| mcpscope::view(&state_dir())).await {
Ok(v) => Json(v).into_response(),
Err(e) => err(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()),
}
}

#[derive(Deserialize)]
struct McpScopeBody {
agents: std::collections::BTreeMap<String, mcpscope::Scope>,
}

/// `PUT /hub/mcp/scope {agents: {<id>: "repository"|"user"}}`: write or
/// remove the user entry of those agents; the agents and why one failed.
async fn mcp_scope_put(Json(b): Json<McpScopeBody>) -> Response {
match tokio::task::spawn_blocking(move || mcpscope::set(&state_dir(), &b.agents)).await {
Ok(Ok(v)) => {
devstack_daemon::diag::info(
"mcp_scope",
serde_json::json!({ "agents": scopes_of(&v) }),
);
Json(v).into_response()
}
Ok(Err(e)) => err(StatusCode::BAD_REQUEST, e),
Err(e) => err(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()),
}
}

/// The agents' scopes, for the diagnostic log.
fn scopes_of(v: &mcpscope::View) -> serde_json::Value {
v.agents
.iter()
.map(|a| {
(
a.id.to_string(),
serde_json::to_value(a.scope).expect("serialises"),
)
})
.collect::<serde_json::Map<_, _>>()
.into()
}

#[derive(Deserialize)]
struct OpenQuery {
stack: String,
Expand Down
Loading