Skip to content

Commit 2d0dd49

Browse files
add get source
1 parent 2f84f07 commit 2d0dd49

File tree

8 files changed

+508
-2
lines changed

8 files changed

+508
-2
lines changed

apps/framework-cli/src/framework/core/infrastructure/api_endpoint.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ impl ApiEndpoint {
131131
metadata: MessageField::from_option(self.metadata.as_ref().map(|m| {
132132
infrastructure_map::Metadata {
133133
description: m.description.clone().unwrap_or_default(),
134+
source: MessageField::from_option(m.source.as_ref().map(|s| {
135+
infrastructure_map::SourceLocation {
136+
file: s.file.clone(),
137+
special_fields: Default::default(),
138+
}
139+
})),
134140
special_fields: Default::default(),
135141
}
136142
})),
@@ -157,6 +163,10 @@ impl ApiEndpoint {
157163
} else {
158164
Some(m.description)
159165
},
166+
source: m
167+
.source
168+
.into_option()
169+
.map(|s| super::table::SourceLocation { file: s.file }),
160170
}),
161171
}
162172
}

apps/framework-cli/src/framework/core/infrastructure/function_process.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ impl FunctionProcess {
135135
metadata: MessageField::from_option(self.metadata.as_ref().map(|m| {
136136
crate::proto::infrastructure_map::Metadata {
137137
description: m.description.clone().unwrap_or_default(),
138+
source: MessageField::from_option(m.source.as_ref().map(|s| {
139+
crate::proto::infrastructure_map::SourceLocation {
140+
file: s.file.clone(),
141+
special_fields: Default::default(),
142+
}
143+
})),
138144
special_fields: Default::default(),
139145
}
140146
})),
@@ -159,6 +165,10 @@ impl FunctionProcess {
159165
} else {
160166
Some(m.description)
161167
},
168+
source: m
169+
.source
170+
.into_option()
171+
.map(|s| super::table::SourceLocation { file: s.file }),
162172
}),
163173
}
164174
}

apps/framework-cli/src/framework/core/infrastructure/table.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ use serde_json::Value;
2222
use std::fmt;
2323
use std::fmt::Debug;
2424

25+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
26+
pub struct SourceLocation {
27+
pub file: String,
28+
}
29+
2530
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Eq, Hash)]
2631
pub struct Metadata {
2732
pub description: Option<String>,
33+
#[serde(skip_serializing_if = "Option::is_none", default)]
34+
pub source: Option<SourceLocation>,
2835
}
2936

3037
/// Prefix for Moose-managed metadata in column comments.
@@ -197,6 +204,12 @@ impl Table {
197204
metadata: MessageField::from_option(self.metadata.as_ref().map(|m| {
198205
infrastructure_map::Metadata {
199206
description: m.description.clone().unwrap_or_default(),
207+
source: MessageField::from_option(m.source.as_ref().map(|s| {
208+
infrastructure_map::SourceLocation {
209+
file: s.file.clone(),
210+
special_fields: Default::default(),
211+
}
212+
})),
200213
special_fields: Default::default(),
201214
}
202215
})),
@@ -241,6 +254,10 @@ impl Table {
241254
} else {
242255
Some(m.description)
243256
},
257+
source: m
258+
.source
259+
.into_option()
260+
.map(|s| SourceLocation { file: s.file }),
244261
}),
245262
life_cycle: match proto.life_cycle.enum_value_or_default() {
246263
ProtoLifeCycle::FULLY_MANAGED => LifeCycle::FullyManaged,

apps/framework-cli/src/framework/core/infrastructure/topic.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ impl Topic {
142142
metadata: MessageField::from_option(self.metadata.as_ref().map(|m| {
143143
proto::infrastructure_map::Metadata {
144144
description: m.description.clone().unwrap_or_default(),
145+
source: MessageField::from_option(m.source.as_ref().map(|s| {
146+
proto::infrastructure_map::SourceLocation {
147+
file: s.file.clone(),
148+
special_fields: Default::default(),
149+
}
150+
})),
145151
special_fields: Default::default(),
146152
}
147153
})),
@@ -181,6 +187,10 @@ impl Topic {
181187
} else {
182188
Some(m.description)
183189
},
190+
source: m
191+
.source
192+
.into_option()
193+
.map(|s| super::table::SourceLocation { file: s.file }),
184194
}),
185195
life_cycle: match proto.life_cycle.enum_value_or_default() {
186196
ProtoLifeCycle::FULLY_MANAGED => LifeCycle::FullyManaged,

apps/framework-cli/src/mcp/server.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rmcp::{
1212
};
1313
use std::sync::Arc;
1414

15-
use super::tools::{create_error_result, infra_map, logs};
15+
use super::tools::{create_error_result, get_source, infra_map, logs};
1616
use crate::infrastructure::redis::redis_client::RedisClient;
1717

1818
/// Handler for the MCP server that implements the Model Context Protocol
@@ -66,7 +66,11 @@ impl ServerHandler for MooseMcpHandler {
6666
_context: RequestContext<RoleServer>,
6767
) -> Result<ListToolsResult, ErrorData> {
6868
Ok(ListToolsResult {
69-
tools: vec![logs::tool_definition(), infra_map::tool_definition()],
69+
tools: vec![
70+
logs::tool_definition(),
71+
infra_map::tool_definition(),
72+
get_source::tool_definition(),
73+
],
7074
next_cursor: None,
7175
})
7276
}
@@ -83,6 +87,11 @@ impl ServerHandler for MooseMcpHandler {
8387
self.redis_client.clone(),
8488
)
8589
.await),
90+
"get_source" => Ok(get_source::handle_call(
91+
param.arguments.as_ref(),
92+
self.redis_client.clone(),
93+
)
94+
.await),
8695
_ => Ok(create_error_result(format!("Unknown tool: {}", param.name))),
8796
}
8897
}

0 commit comments

Comments
 (0)