Skip to content
Closed
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
11 changes: 7 additions & 4 deletions golem-worker-service/src/mcp/agent_mcp_capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use crate::mcp::agent_mcp_resource::AgentMcpResource;
use crate::mcp::agent_mcp_tool::AgentMcpTool;
use crate::mcp::mcp_schema::{GetMcpSchema, GetMcpToolSchema, McpToolSchema};
use crate::mcp::schema::{GetMcpSchema, GetMcpToolSchema, McpSchema, McpToolSchema};
use golem_common::base_model::account::AccountId;
use golem_common::base_model::agent::{AgentMethod, AgentTypeName, DataSchema};
use golem_common::base_model::component::ComponentId;
Expand Down Expand Up @@ -50,8 +50,10 @@ impl McpAgentCapability {
);

let constructor_schema = constructor.input_schema.get_mcp_schema();

let mut tool_schema = method.get_mcp_tool_schema();
tool_schema.merge_input_schema(constructor_schema);

tool_schema.prepend_input_schema(constructor_schema);

let McpToolSchema {
input_schema,
Expand All @@ -62,8 +64,9 @@ impl McpAgentCapability {
name: Cow::from(get_tool_name(agent_type_name, method)),
title: None,
description: Some(method.description.clone().into()),
input_schema: Arc::new(input_schema),
output_schema: output_schema.map(Arc::new),
input_schema: Arc::new(McpSchema::from(input_schema)),
output_schema: output_schema
.map(|internal| Arc::new(McpSchema::from(internal))),
annotations: None,
execution: None,
icons: None,
Expand Down
16 changes: 12 additions & 4 deletions golem-worker-service/src/mcp/agent_mcp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use golem_common::base_model::agent::{
use golem_common::base_model::domain_registration::Domain;
use golem_common::model::WorkerId;
use golem_common::model::agent::{NamedElementSchema, UntypedDataValue, UntypedElementValue};
use golem_wasm::analysis::AnalysedType;
use golem_wasm::json::ValueAndTypeJsonExtensions;
use golem_wasm::{IntoValue, ValueAndType};
use poem::http;
Expand Down Expand Up @@ -186,12 +187,19 @@ where
{
match elem_schema {
ElementSchema::ComponentModel(ComponentModelElementSchema { element_type }) => {
let value = args_map
.get(name)
.ok_or_else(|| format!("Missing parameter: {}", name))?;
let json_value = match args_map.get(name) {
Some(value) => value.clone(),
None => {
if matches!(element_type, AnalysedType::Option(_)) {
serde_json::Value::Null
} else {
return Err(format!("Missing parameter: {}", name));
}
}
};

let value_and_type =
golem_wasm::ValueAndType::parse_with_type(value, element_type)
golem_wasm::ValueAndType::parse_with_type(&json_value, element_type)
.map_err(|errs| {
format!(
"Failed to parse parameter '{}': {}",
Expand Down
116 changes: 0 additions & 116 deletions golem-worker-service/src/mcp/mcp_schema.rs

This file was deleted.

2 changes: 1 addition & 1 deletion golem-worker-service/src/mcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mod agent_mcp_resource;
mod agent_mcp_server;
mod agent_mcp_tool;
mod mcp_capabilities_lookup;
mod mcp_schema;
mod schema;
Loading
Loading