Skip to content

Commit f12f538

Browse files
committed
add web_apps to moose ls and dev MCP
1 parent 3d1c6ba commit f12f538

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

apps/framework-cli/src/cli/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub enum Commands {
141141
Ps {},
142142
/// View Moose primitives & infrastructure
143143
Ls {
144-
/// Filter by infrastructure type (tables, streams, ingestion, sql_resource, consumption)
144+
/// Filter by infrastructure type (tables, streams, ingestion, sql_resource, consumption, workflows, web_apps)
145145
#[arg(long)]
146146
_type: Option<String>,
147147

apps/framework-cli/src/cli/routines/ls.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::framework::core::infrastructure::api_endpoint::{APIType, ApiEndpoint}
88
use crate::framework::core::infrastructure::function_process::FunctionProcess;
99
use crate::framework::core::infrastructure::topic::Topic;
1010
use crate::framework::core::infrastructure::topic_sync_process::TopicToTableSyncProcess;
11+
use crate::framework::core::infrastructure::web_app::WebApp;
1112
use crate::framework::core::infrastructure_map::InfrastructureMap;
1213
use crate::framework::scripts::Workflow;
1314
use crate::{
@@ -260,6 +261,36 @@ impl From<Workflow> for WorkflowInfo {
260261
}
261262
}
262263

264+
#[derive(Debug, Serialize)]
265+
pub struct WebAppInfo {
266+
pub name: String,
267+
pub mount_path: String,
268+
}
269+
270+
impl From<WebApp> for WebAppInfo {
271+
fn from(value: WebApp) -> Self {
272+
Self {
273+
name: value.name,
274+
mount_path: value.mount_path,
275+
}
276+
}
277+
}
278+
279+
impl ResourceInfo for Vec<WebAppInfo> {
280+
fn show(&self) {
281+
show_table(
282+
"Web Apps".to_string(),
283+
vec!["name".to_string(), "mount_path".to_string()],
284+
self.iter()
285+
.map(|app| vec![app.name.clone(), app.mount_path.clone()])
286+
.collect(),
287+
)
288+
}
289+
fn to_json_string(&self) -> Result<String, Error> {
290+
serde_json::to_string_pretty(&self)
291+
}
292+
}
293+
263294
#[derive(Debug, Serialize)]
264295
pub struct ResourceListing {
265296
pub tables: Vec<TableInfo>,
@@ -269,6 +300,7 @@ pub struct ResourceListing {
269300
pub consumption_apis: Vec<ConsumptionApiInfo>,
270301
pub stream_transformations: Vec<StreamTransformationInfo>,
271302
pub workflows: Vec<WorkflowInfo>,
303+
pub web_apps: Vec<WebAppInfo>,
272304
}
273305

274306
impl ResourceInfo for ResourceListing {
@@ -280,6 +312,7 @@ impl ResourceInfo for ResourceListing {
280312
self.consumption_apis.show();
281313
self.stream_transformations.show();
282314
self.workflows.show();
315+
self.web_apps.show();
283316
}
284317

285318
fn to_json_string(&self) -> Result<String, Error> {
@@ -351,6 +384,12 @@ pub async fn ls_dmv2(
351384
.filter(|api| name.is_none_or(|name| api.name().contains(name)))
352385
.map(|w| w.into())
353386
.collect(),
387+
web_apps: infra_map
388+
.web_apps
389+
.into_values()
390+
.filter(|app| name.is_none_or(|n| app.name.contains(n)))
391+
.map(|w| w.into())
392+
.collect(),
354393
};
355394
let listing: &dyn ResourceInfo = match _type {
356395
None => &resources,
@@ -360,6 +399,7 @@ pub async fn ls_dmv2(
360399
Some("sql_resource") => &resources.sql_resources,
361400
Some("consumption") => &resources.consumption_apis,
362401
Some("workflows") => &resources.workflows,
402+
Some("web_apps") => &resources.web_apps,
363403
_ => {
364404
return Err(RoutineFailure::error(Message::new(
365405
"Unknown".to_string(),

apps/framework-cli/src/mcp/tools/infra_map.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::infrastructure::redis::redis_client::RedisClient;
1616
/// Valid component types for filtering
1717
/// Note: block_db_processes and consumption_api_web_server are single structs, not collections,
1818
/// so they are not included in this list yet. They can be added when they become HashMaps.
19-
const VALID_COMPONENT_TYPES: [&str; 10] = [
19+
const VALID_COMPONENT_TYPES: [&str; 11] = [
2020
"topics",
2121
"api_endpoints",
2222
"tables",
@@ -27,6 +27,7 @@ const VALID_COMPONENT_TYPES: [&str; 10] = [
2727
"orchestration_workers",
2828
"sql_resources",
2929
"workflows",
30+
"web_apps",
3031
];
3132

3233
/// Valid format options
@@ -122,7 +123,7 @@ pub fn tool_definition() -> Tool {
122123
Tool {
123124
name: "get_infra_map".into(),
124125
description: Some(
125-
"Retrieve and explore the Moose infrastructure map. Access all infrastructure components including tables, topics, API endpoints, sync processes, function processes, orchestration workers, SQL resources, and workflows. Filter by component type and search with regex patterns.".into()
126+
"Retrieve and explore the Moose infrastructure map. Access all infrastructure components including tables, topics, API endpoints, sync processes, function processes, orchestration workers, SQL resources, workflows, and web apps. Filter by component type and search with regex patterns.".into()
126127
),
127128
input_schema: Arc::new(schema.as_object().unwrap().clone()),
128129
annotations: None,
@@ -449,6 +450,14 @@ fn format_summary(
449450
component_type_filter,
450451
show_all,
451452
),
453+
process_component_summary(
454+
"web_apps",
455+
"Web Apps",
456+
&infra_map.web_apps,
457+
search,
458+
component_type_filter,
459+
show_all,
460+
),
452461
];
453462

454463
// Append all non-empty component sections
@@ -559,6 +568,13 @@ fn format_detailed(
559568
component_type_filter,
560569
show_all,
561570
)?,
571+
process_component_detailed(
572+
"web_apps",
573+
&infra_map.web_apps,
574+
search,
575+
component_type_filter,
576+
show_all,
577+
)?,
562578
];
563579

564580
// Add all non-empty components to the filtered map
@@ -600,6 +616,7 @@ mod tests {
600616
assert!(is_valid_component_type("tables"));
601617
assert!(is_valid_component_type("api_endpoints"));
602618
assert!(is_valid_component_type("workflows"));
619+
assert!(is_valid_component_type("web_apps"));
603620

604621
assert!(!is_valid_component_type("invalid"));
605622
assert!(!is_valid_component_type(""));

0 commit comments

Comments
 (0)