Skip to content
Draft
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
4 changes: 4 additions & 0 deletions agentschema-emitter/lib/model/tools/mcp.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ model McpTool extends Tool {
@doc("List of allowed operations or resources for the MCP tool")
@sample(#{ allowedTools: #["operation1", "operation2"] })
allowedTools?: string[];

@doc("Custom HTTP headers to include in requests to the MCP server, useful for authentication or routing")
@sample(#{ headers: #{ Authorization: "Bearer token" } })
headers?: Record<string>;
}

alias mcpApprovalMode = "always" | "never" | "specify";
Expand Down
7 changes: 0 additions & 7 deletions agentschema-emitter/package-lock.json

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

2 changes: 1 addition & 1 deletion agentschema-emitter/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export const resolveModelProperty = (program: Program, property: ModelProperty,
prop.isCollection = false;

prop.typeName = getModelType(model, rootNamespace, rootAlias);
if (prop.typeName.name === "Record<unknown>") {
if (prop.typeName.name === "Record<unknown>" || prop.typeName.name === "Record<string>") {
prop.isScalar = true;
prop.isDict = true;
prop.typeName = {
Expand Down
4 changes: 4 additions & 0 deletions docs/src/content/docs/reference/McpTool.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ classDiagram
+string serverDescription
+McpServerApprovalMode approvalMode
+string[] allowedTools
+dictionary headers
}
class McpServerApprovalMode {
+string kind
Expand All @@ -53,6 +54,8 @@ approvalMode:
allowedTools:
- operation1
- operation2
headers:
Authorization: Bearer token
```

## Properties
Expand All @@ -65,6 +68,7 @@ allowedTools:
| serverDescription | string | The description of the MCP tool |
| approvalMode | [McpServerApprovalMode](../mcpserverapprovalmode/) | The approval mode for the MCP tool, either &#39;auto&#39; or &#39;manual&#39;(Related Types: [McpServerToolAlwaysRequireApprovalMode](../mcpservertoolalwaysrequireapprovalmode/), [McpServerToolNeverRequireApprovalMode](../mcpservertoolneverrequireapprovalmode/), [McpServerToolSpecifyApprovalMode](../mcpservertoolspecifyapprovalmode/)) |
| allowedTools | string[] | List of allowed operations or resources for the MCP tool |
| headers | dictionary | Custom HTTP headers to include in requests to the MCP server, useful for authentication or routing |

## Composed Types

Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/reference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ classDiagram
+string serverDescription
+McpServerApprovalMode approvalMode
+string[] allowedTools
+dictionary headers
}
class OpenApiTool {

Expand Down
24 changes: 24 additions & 0 deletions docs/src/content/docs/reference/Record<string>.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Record&lt;string&gt;"
description: "Documentation for the Record&lt;string&gt; type."
slug: "reference/record&lt;string&gt;"
---



## Class Diagram

```mermaid
---
title: Record&lt;string&gt;
config:
look: handDrawn
theme: colorful
class:
hideEmptyMembersBox: true
---
classDiagram
class Record&lt;string&gt; {

}
```
1 change: 1 addition & 0 deletions docs/src/content/docs/reference/Tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ classDiagram
+string serverDescription
+McpServerApprovalMode approvalMode
+string[] allowedTools
+dictionary headers
}
Tool <|-- McpTool
class OpenApiTool {
Expand Down
21 changes: 18 additions & 3 deletions runtime/csharp/AgentSchema.Tests/McpToolConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public void LoadYamlInput()
allowedTools:
- operation1
- operation2
headers:
Authorization: Bearer token

""";

Expand Down Expand Up @@ -50,7 +52,10 @@ public void LoadJsonInput()
"allowedTools": [
"operation1",
"operation2"
]
],
"headers": {
"Authorization": "Bearer token"
}
}
""";

Expand Down Expand Up @@ -79,7 +84,10 @@ public void RoundtripJson()
"allowedTools": [
"operation1",
"operation2"
]
],
"headers": {
"Authorization": "Bearer token"
}
}
""";

Expand Down Expand Up @@ -111,6 +119,8 @@ public void RoundtripYaml()
allowedTools:
- operation1
- operation2
headers:
Authorization: Bearer token

""";

Expand Down Expand Up @@ -144,7 +154,10 @@ public void ToJsonProducesValidJson()
"allowedTools": [
"operation1",
"operation2"
]
],
"headers": {
"Authorization": "Bearer token"
}
}
""";

Expand All @@ -170,6 +183,8 @@ public void ToYamlProducesValidYaml()
allowedTools:
- operation1
- operation2
headers:
Authorization: Bearer token

""";

Expand Down
15 changes: 15 additions & 0 deletions runtime/csharp/AgentSchema/McpTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public McpTool()
/// </summary>
public IList<string>? AllowedTools { get; set; }

/// <summary>
/// Custom HTTP headers to include in requests to the MCP server, useful for authentication or routing
/// </summary>
public IDictionary<string, object>? Headers { get; set; }


#region Load Methods

Expand Down Expand Up @@ -106,6 +111,11 @@ public McpTool()
instance.AllowedTools = (allowedToolsValue as IEnumerable<object>)?.Select(x => x?.ToString()!).ToList() ?? [];
}

if (data.TryGetValue("headers", out var headersValue) && headersValue is not null)
{
instance.Headers = headersValue.GetDictionary()!;
}

if (context is not null)
{
instance = context.ProcessOutput(instance);
Expand Down Expand Up @@ -167,6 +177,11 @@ public McpTool()
result["allowedTools"] = obj.AllowedTools;
}

if (obj.Headers is not null)
{
result["headers"] = obj.Headers;
}


return result;
}
Expand Down
22 changes: 18 additions & 4 deletions runtime/go/agentschema/mcp_tool_test.go

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

21 changes: 15 additions & 6 deletions runtime/go/agentschema/tool.go

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

Loading