41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import yaml
|
|
import json
|
|
import glob
|
|
import sys
|
|
|
|
def main():
|
|
tools = []
|
|
|
|
# cmm 폴더의 yaml 파일들을 읽습니다.
|
|
files = glob.glob('dap-was-cus/src/main/resources/tool-definitions/cmm/*.yml')
|
|
if not files:
|
|
files = glob.glob('dap-was-sal/src/main/resources/tool-definitions/cmm/*.yml')
|
|
|
|
for f in files:
|
|
with open(f, 'r', encoding='utf-8') as file:
|
|
data = yaml.safe_load(file)
|
|
|
|
# MCP JSON Schema 규격에 맞게 변환
|
|
tool = {
|
|
"name": data.get("name"),
|
|
"description": data.get("description", {}).get("function", "") if isinstance(data.get("description"), dict) else data.get("description", ""),
|
|
"inputSchema": data.get("parameters_schema", {
|
|
"type": "object",
|
|
"properties": {}
|
|
})
|
|
}
|
|
tools.append(tool)
|
|
|
|
response = {
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"result": {
|
|
"tools": tools
|
|
}
|
|
}
|
|
|
|
print(json.dumps(response, indent=2, ensure_ascii=False))
|
|
|
|
if __name__ == '__main__':
|
|
main()
|