enable mcp for tool for all endpoints

This commit is contained in:
Tanmay Deep Sharma
2025-06-02 16:12:38 +05:30
parent 65ac19718f
commit 9b0ff544f9
6 changed files with 42 additions and 24 deletions
+22 -4
View File
@@ -23,8 +23,8 @@ module SwaggerTaskActions
logging: true
)
# Add x-mcp property to the final build
final_build['x-mcp'] = { 'enabled' => true }
# Add x-mcp property right after openapi version
final_build = _insert_x_mcp_after_openapi(final_build)
File.write(swagger_json_relative_path, JSON.pretty_generate(final_build))
@@ -90,8 +90,8 @@ module SwaggerTaskActions
tag_spec['paths'] = _filter_paths_for_tag_group(tag_spec['paths'], tags_in_current_group)
tag_spec['tags'] = _filter_tags_for_tag_group(tag_spec['tags'], tags_in_current_group)
# Add x-mcp property to the tag spec
tag_spec['x-mcp'] = { 'enabled' => true }
# Add x-mcp property right after openapi version
tag_spec = _insert_x_mcp_after_openapi(tag_spec)
output_filename = _determine_output_filename(group_name)
File.write(output_dir.join(output_filename), JSON.pretty_generate(tag_spec))
@@ -142,6 +142,24 @@ module SwaggerTaskActions
puts "Warning: Source file #{source_file_path} not found. Skipping symlink for #{File.basename(target_file_path)}."
end
end
def _insert_x_mcp_after_openapi(spec)
ordered_spec = {}
# First add openapi version
ordered_spec['openapi'] = spec['openapi'] if spec.key?('openapi')
# Then add x-mcp property
ordered_spec['x-mcp'] = { 'enabled' => true }
# Then add all other properties in their original order
spec.each do |key, value|
next if key == 'openapi' # Skip since we already added it
ordered_spec[key] = value
end
ordered_spec
end
end
end
+4 -4
View File
@@ -1,5 +1,8 @@
{
"openapi": "3.0.4",
"x-mcp": {
"enabled": true
},
"info": {
"title": "Chatwoot",
"description": "This is the API documentation for Chatwoot server.",
@@ -11851,8 +11854,5 @@
"CSAT Survey Page"
]
}
],
"x-mcp": {
"enabled": true
}
]
}
+4 -4
View File
@@ -1,5 +1,8 @@
{
"openapi": "3.0.4",
"x-mcp": {
"enabled": true
},
"info": {
"title": "Chatwoot",
"description": "This is the API documentation for Chatwoot server.",
@@ -10180,8 +10183,5 @@
"CSAT Survey Page"
]
}
],
"x-mcp": {
"enabled": true
}
]
}
+4 -4
View File
@@ -1,5 +1,8 @@
{
"openapi": "3.0.4",
"x-mcp": {
"enabled": true
},
"info": {
"title": "Chatwoot",
"description": "This is the API documentation for Chatwoot server.",
@@ -4959,8 +4962,5 @@
"CSAT Survey Page"
]
}
],
"x-mcp": {
"enabled": true
}
]
}
+4 -4
View File
@@ -1,5 +1,8 @@
{
"openapi": "3.0.4",
"x-mcp": {
"enabled": true
},
"info": {
"title": "Chatwoot",
"description": "This is the API documentation for Chatwoot server.",
@@ -4366,8 +4369,5 @@
"CSAT Survey Page"
]
}
],
"x-mcp": {
"enabled": true
}
]
}
+4 -4
View File
@@ -1,5 +1,8 @@
{
"openapi": "3.0.4",
"x-mcp": {
"enabled": true
},
"info": {
"title": "Chatwoot",
"description": "This is the API documentation for Chatwoot server.",
@@ -5139,8 +5142,5 @@
"CSAT Survey Page"
]
}
],
"x-mcp": {
"enabled": true
}
]
}