-
Notifications
You must be signed in to change notification settings - Fork 727
Closed
Description
Problem Statement
I want to test server.MCPServer which have following code fragment
// Table Structure Template Resource
tableTemplate := mcp.NewResourceTemplate(
"clickhouse://table/{table_name}",
"Table Structure",
mcp.WithTemplateDescription("Detailed structure information for a specific table"),
mcp.WithTemplateMIMEType("application/json"),
)
srv.AddResourceTemplate(tableTemplate, func(ctx context.Context, req mcp.ReadResourceRequest) ([]mcp.ResourceContents, error) {
// Extract table name from URI
uri := req.Params.URI
parts := strings.Split(uri, "/")
if len(parts) < 3 {
return nil, fmt.Errorf("invalid table URI format")
}
tableName := parts[len(parts)-1]
log.Debug().Str("table", tableName).Msg("Reading table structure resource")
columns, err := chClient.DescribeTable(ctx, tableName)
if err != nil {
return nil, fmt.Errorf("failed to get table structure: %w", err)
}
jsonData, err := json.MarshalIndent(columns, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to marshal table structure: %w", err)
}
return []mcp.ResourceContents{
mcp.TextResourceContents{
URI: uri,
MIMEType: "application/json",
Text: string(jsonData),
},
}, nil
})
Proposed Solution
Add something like that
func (s *mcptest.Server) AddResourceTemplate(template mcp.ResourceTemplate, handler server.ResourceTemplateHandlerFunc) {
}
Metadata
Metadata
Assignees
Labels
No labels