connect-mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Plugin_generator/Generated_Plugins/cowork_plugin/.claude-plugin/plugin.json +8 -0
- package/Plugin_generator/Generated_Plugins/cowork_plugin/.mcp.json +9 -0
- package/Plugin_generator/Generated_Plugins/cowork_plugin/README.md +60 -0
- package/Plugin_generator/Generated_Plugins/cowork_plugin/skills/approve_loan/SKILL.md +14 -0
- package/Plugin_generator/Generated_Plugins/cowork_plugin/skills/create_loan/SKILL.md +14 -0
- package/Plugin_generator/Generated_Plugins/cowork_plugin/skills/get_loan/SKILL.md +14 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/.claude-plugin/plugin.json +8 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/.mcp.json +9 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/README.md +60 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/skills/approve_loan/SKILL.md +14 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/skills/create_loan/SKILL.md +14 -0
- package/Plugin_generator/Generated_Plugins/temp_plugin/skills/delete_loan/SKILL.md +14 -0
- package/Plugin_generator/__init__.py +0 -0
- package/Plugin_generator/__pycache__/config.cpython-312.pyc +0 -0
- package/Plugin_generator/config.py +9 -0
- package/Plugin_generator/generators/__init__.py +0 -0
- package/Plugin_generator/generators/__pycache__/__init__.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/base.py +0 -0
- package/Plugin_generator/generators/claude/__init__.py +0 -0
- package/Plugin_generator/generators/claude/__pycache__/__init__.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/claude/__pycache__/mcp_config.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/claude/__pycache__/plugin.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/claude/__pycache__/readme.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/claude/__pycache__/skills.cpython-312.pyc +0 -0
- package/Plugin_generator/generators/claude/mcp_config.py +18 -0
- package/Plugin_generator/generators/claude/plugin.py +21 -0
- package/Plugin_generator/generators/claude/readme.py +91 -0
- package/Plugin_generator/generators/claude/skills.py +42 -0
- package/Plugin_generator/main.py +101 -0
- package/Plugin_generator/mcp_local/__pycache__/client.cpython-312.pyc +0 -0
- package/Plugin_generator/mcp_local/__pycache__/discovery.cpython-312.pyc +0 -0
- package/Plugin_generator/mcp_local/client.py +11 -0
- package/Plugin_generator/mcp_local/discovery.py +14 -0
- package/Plugin_generator/requirements.txt +4 -0
- package/Plugin_generator/utils/__init__.py +0 -0
- package/Plugin_generator/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- package/Plugin_generator/utils/__pycache__/file_utils.cpython-312.pyc +0 -0
- package/Plugin_generator/utils/file_utils.py +16 -0
- package/README.MD +188 -4
- package/commands/cowork.js +25 -0
- package/index.html +816 -0
- package/index.js +38 -9
- package/package.json +2 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Loan MCP Plugin
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This plugin enables Claude to interact with a loan system using MCP tools.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Capabilities
|
|
10
|
+
|
|
11
|
+
- Create Loan
|
|
12
|
+
- Get Loan
|
|
13
|
+
- Approve Loan
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Available Tools
|
|
19
|
+
- **create_loan**: Create a new loan for a borrower with a specified amount
|
|
20
|
+
- **get_loan**: Fetch loan details using the loan ID
|
|
21
|
+
- **approve_loan**: Approve an existing loan by loan ID
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
Claude (CoWork)
|
|
29
|
+
|
|
|
30
|
+
v
|
|
31
|
+
Claude Plugin
|
|
32
|
+
|
|
|
33
|
+
v
|
|
34
|
+
MCP Server (SSE)
|
|
35
|
+
|
|
|
36
|
+
v
|
|
37
|
+
Backend System
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## How It Works
|
|
42
|
+
|
|
43
|
+
- Claude reads skills from the `skills/` directory
|
|
44
|
+
- Each skill maps to an MCP tool
|
|
45
|
+
- The MCP server executes tool calls
|
|
46
|
+
- Results are returned to Claude
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Notes
|
|
51
|
+
|
|
52
|
+
- MCP server must be running and accessible
|
|
53
|
+
- Uses SSE transport
|
|
54
|
+
- Plugin generated automatically from MCP server
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Author
|
|
59
|
+
|
|
60
|
+
Your Name
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: approve_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: approve_loan
|
|
6
|
+
description: Approve an existing loan by loan ID
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the approve_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to approve_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `approve_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: create_loan
|
|
6
|
+
description: Create a new loan for a borrower with a specified amount
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the create_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to create_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `create_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: get_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: get_loan
|
|
6
|
+
description: Fetch loan details using the loan ID
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the get_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to get_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `get_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Loan MCP Plugin
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This plugin enables Claude to interact with a loan system using MCP tools.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Capabilities
|
|
10
|
+
|
|
11
|
+
- Create Loan
|
|
12
|
+
- Approve Loan
|
|
13
|
+
- Delete Loan
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Available Tools
|
|
19
|
+
- **create_loan**: Create a loan for a borrower
|
|
20
|
+
- **approve_loan**: Approve a loan for a borrower
|
|
21
|
+
- **delete_loan**: Delete a loan for a borrower
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
Claude (CoWork)
|
|
29
|
+
|
|
|
30
|
+
v
|
|
31
|
+
Claude Plugin
|
|
32
|
+
|
|
|
33
|
+
v
|
|
34
|
+
MCP Server (SSE)
|
|
35
|
+
|
|
|
36
|
+
v
|
|
37
|
+
Backend System
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## How It Works
|
|
42
|
+
|
|
43
|
+
- Claude reads skills from the `skills/` directory
|
|
44
|
+
- Each skill maps to an MCP tool
|
|
45
|
+
- The MCP server executes tool calls
|
|
46
|
+
- Results are returned to Claude
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Notes
|
|
51
|
+
|
|
52
|
+
- MCP server must be running and accessible
|
|
53
|
+
- Uses SSE transport
|
|
54
|
+
- Plugin generated automatically from MCP server
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Author
|
|
59
|
+
|
|
60
|
+
Your Name
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: approve_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: approve_loan
|
|
6
|
+
description: Approve a loan for a borrower
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the approve_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to approve_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `approve_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: create_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: create_loan
|
|
6
|
+
description: Create a loan for a borrower
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the create_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to create_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `create_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: delete_loan
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
name: delete_loan
|
|
6
|
+
description: Delete a loan for a borrower
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
When using the delete_loan tool:
|
|
10
|
+
|
|
11
|
+
1. Understand the user's request related to delete_loan
|
|
12
|
+
2. Confirm any required details before calling the tool
|
|
13
|
+
3. Use the `delete_loan` MCP tool to perform the operation
|
|
14
|
+
4. Return the result clearly to the user
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from utils.file_utils import write_json
|
|
3
|
+
from config import MCP_SERVER_URL, PLUGIN_NAME
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def create_mcp_config(plugin_root):
|
|
7
|
+
|
|
8
|
+
config = {
|
|
9
|
+
"servers": [
|
|
10
|
+
{
|
|
11
|
+
"name": PLUGIN_NAME,
|
|
12
|
+
"url": MCP_SERVER_URL,
|
|
13
|
+
"transport": "sse"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
write_json(os.path.join(plugin_root, ".mcp.json"), config)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from utils.file_utils import ensure_dir, write_json
|
|
3
|
+
from config import PLUGIN_NAME, PLUGIN_DESCRIPTION, AUTHOR_NAME
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def create_plugin_json(plugin_root):
|
|
7
|
+
|
|
8
|
+
plugin_dir = os.path.join(plugin_root, ".claude-plugin")
|
|
9
|
+
|
|
10
|
+
ensure_dir(plugin_dir)
|
|
11
|
+
|
|
12
|
+
plugin_json = {
|
|
13
|
+
"name": PLUGIN_NAME,
|
|
14
|
+
"description": PLUGIN_DESCRIPTION,
|
|
15
|
+
"version": "1.0.0",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": AUTHOR_NAME
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
write_json(os.path.join(plugin_dir, "plugin.json"), plugin_json)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from utils.file_utils import write_file
|
|
3
|
+
from config import AUTHOR_NAME
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def create_readme(plugin_root, tools):
|
|
7
|
+
|
|
8
|
+
readme_path = os.path.join(plugin_root, "README.md")
|
|
9
|
+
|
|
10
|
+
capabilities = ""
|
|
11
|
+
for tool in tools:
|
|
12
|
+
readable_name = tool["name"].replace("_", " ").title()
|
|
13
|
+
capabilities += f"- {readable_name}\n"
|
|
14
|
+
|
|
15
|
+
words = []
|
|
16
|
+
for tool in tools:
|
|
17
|
+
words.extend(tool["name"].split("_"))
|
|
18
|
+
|
|
19
|
+
common_words = {}
|
|
20
|
+
for w in words:
|
|
21
|
+
common_words[w] = common_words.get(w, 0) + 1
|
|
22
|
+
|
|
23
|
+
sorted_words = sorted(common_words.items(), key=lambda x: -x[1])
|
|
24
|
+
|
|
25
|
+
domain_word = sorted_words[0][0] if sorted_words else "MCP"
|
|
26
|
+
domain_title = domain_word.capitalize()
|
|
27
|
+
|
|
28
|
+
overview = f"This plugin enables Claude to interact with a {domain_title.lower()} system using MCP tools."
|
|
29
|
+
|
|
30
|
+
content = f"""# {domain_title} MCP Plugin
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
{overview}
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Capabilities
|
|
39
|
+
|
|
40
|
+
{capabilities}
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Available Tools
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
for tool in tools:
|
|
48
|
+
content += f"- **{tool['name']}**: {tool.get('description', '')}\n"
|
|
49
|
+
|
|
50
|
+
content += f"""
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
Claude (CoWork)
|
|
57
|
+
|
|
|
58
|
+
v
|
|
59
|
+
Claude Plugin
|
|
60
|
+
|
|
|
61
|
+
v
|
|
62
|
+
MCP Server (SSE)
|
|
63
|
+
|
|
|
64
|
+
v
|
|
65
|
+
Backend System
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## How It Works
|
|
70
|
+
|
|
71
|
+
- Claude reads skills from the `skills/` directory
|
|
72
|
+
- Each skill maps to an MCP tool
|
|
73
|
+
- The MCP server executes tool calls
|
|
74
|
+
- Results are returned to Claude
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Notes
|
|
79
|
+
|
|
80
|
+
- MCP server must be running and accessible
|
|
81
|
+
- Uses SSE transport
|
|
82
|
+
- Plugin generated automatically from MCP server
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Author
|
|
87
|
+
|
|
88
|
+
{AUTHOR_NAME}
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
write_file(readme_path, content)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from utils.file_utils import ensure_dir, write_file
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def create_skill(tool, skills_dir):
|
|
6
|
+
|
|
7
|
+
tool_name = tool["name"]
|
|
8
|
+
description = tool.get("description", "No description provided.")
|
|
9
|
+
|
|
10
|
+
skill_folder = os.path.join(skills_dir, tool_name)
|
|
11
|
+
|
|
12
|
+
ensure_dir(skill_folder)
|
|
13
|
+
|
|
14
|
+
skill_path = os.path.join(skill_folder, "SKILL.md")
|
|
15
|
+
|
|
16
|
+
content = f"""---
|
|
17
|
+
name: {tool_name}
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
name: {tool_name}
|
|
21
|
+
description: {description}
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
When using the {tool_name} tool:
|
|
25
|
+
|
|
26
|
+
1. Understand the user's request related to {tool_name}
|
|
27
|
+
2. Confirm any required details before calling the tool
|
|
28
|
+
3. Use the `{tool_name}` MCP tool to perform the operation
|
|
29
|
+
4. Return the result clearly to the user
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
write_file(skill_path, content)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def generate_skills(tools, plugin_root):
|
|
36
|
+
|
|
37
|
+
skills_dir = os.path.join(plugin_root, "skills")
|
|
38
|
+
|
|
39
|
+
ensure_dir(skills_dir)
|
|
40
|
+
|
|
41
|
+
for tool in tools:
|
|
42
|
+
create_skill(tool, skills_dir)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
import traceback
|
|
5
|
+
import argparse
|
|
6
|
+
|
|
7
|
+
# Fix import path
|
|
8
|
+
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
9
|
+
|
|
10
|
+
from mcp.client.sse import sse_client
|
|
11
|
+
from mcp.client.session import ClientSession
|
|
12
|
+
|
|
13
|
+
from mcp_local.discovery import discover_tools
|
|
14
|
+
|
|
15
|
+
from generators.claude.plugin import create_plugin_json
|
|
16
|
+
from generators.claude.skills import generate_skills
|
|
17
|
+
from generators.claude.readme import create_readme
|
|
18
|
+
from generators.claude.mcp_config import create_mcp_config
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# ---------------------------
|
|
22
|
+
# CLI ARGUMENT PARSER
|
|
23
|
+
# ---------------------------
|
|
24
|
+
def parse_args():
|
|
25
|
+
parser = argparse.ArgumentParser(description="MCP Plugin Generator")
|
|
26
|
+
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"--url",
|
|
29
|
+
type=str,
|
|
30
|
+
required=True,
|
|
31
|
+
help="MCP server URL (must include /mcp)"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"--type",
|
|
36
|
+
type=str,
|
|
37
|
+
default="cowork",
|
|
38
|
+
choices=["cowork", "code"],
|
|
39
|
+
help="Plugin type"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
return parser.parse_args()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# ---------------------------
|
|
46
|
+
# MAIN LOGIC
|
|
47
|
+
# ---------------------------
|
|
48
|
+
async def run_generator(url, plugin_type):
|
|
49
|
+
|
|
50
|
+
print(f"\n Starting MCP Plugin Generation ({plugin_type})")
|
|
51
|
+
print(f" URL: {url}\n")
|
|
52
|
+
|
|
53
|
+
# ✅ Dynamic output folder
|
|
54
|
+
base_output = os.path.join(os.getcwd(), "Generated_Plugins")
|
|
55
|
+
output_dir = os.path.join(base_output, f"{plugin_type}_plugin")
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
print(" Discovering MCP tools...")
|
|
59
|
+
|
|
60
|
+
async with sse_client(
|
|
61
|
+
url,
|
|
62
|
+
headers={"ngrok-skip-browser-warning": "true"}
|
|
63
|
+
) as streams:
|
|
64
|
+
|
|
65
|
+
async with ClientSession(*streams) as session:
|
|
66
|
+
|
|
67
|
+
# Initialize session
|
|
68
|
+
await session.initialize()
|
|
69
|
+
|
|
70
|
+
# Discover tools
|
|
71
|
+
tools = await discover_tools(session)
|
|
72
|
+
|
|
73
|
+
print(f" Found {len(tools)} tools")
|
|
74
|
+
|
|
75
|
+
# Ensure output directory
|
|
76
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
77
|
+
|
|
78
|
+
# Generate files
|
|
79
|
+
create_plugin_json(output_dir)
|
|
80
|
+
create_mcp_config(output_dir)
|
|
81
|
+
create_readme(output_dir, tools)
|
|
82
|
+
generate_skills(tools, output_dir)
|
|
83
|
+
|
|
84
|
+
print("\n Plugin generated successfully!")
|
|
85
|
+
print(f" Location: {output_dir}")
|
|
86
|
+
|
|
87
|
+
except Exception as e:
|
|
88
|
+
print("\n Error occurred:")
|
|
89
|
+
traceback.print_exc()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# ---------------------------
|
|
93
|
+
# ENTRY POINT
|
|
94
|
+
# ---------------------------
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
args = parse_args()
|
|
97
|
+
|
|
98
|
+
if not args.url.endswith("/mcp"):
|
|
99
|
+
print(" Warning: URL should end with /mcp")
|
|
100
|
+
|
|
101
|
+
asyncio.run(run_generator(args.url, args.type))
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from mcp.client.sse import sse_client
|
|
2
|
+
from mcp.client.session import ClientSession
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def create_session(mcp_url):
|
|
6
|
+
streams = await sse_client(mcp_url).__aenter__()
|
|
7
|
+
session = await ClientSession(*streams).__aenter__()
|
|
8
|
+
|
|
9
|
+
await session.initialize()
|
|
10
|
+
|
|
11
|
+
return session, streams
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
async def discover_tools(session):
|
|
2
|
+
|
|
3
|
+
tools_response = await session.list_tools()
|
|
4
|
+
|
|
5
|
+
tools = []
|
|
6
|
+
|
|
7
|
+
for tool in tools_response.tools:
|
|
8
|
+
tools.append({
|
|
9
|
+
"name": tool.name,
|
|
10
|
+
"description": tool.description,
|
|
11
|
+
"parameters": tool.inputSchema
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
return tools
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def ensure_dir(path):
|
|
6
|
+
os.makedirs(path, exist_ok=True)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def write_json(path, data):
|
|
10
|
+
with open(path, "w") as f:
|
|
11
|
+
json.dump(data, f, indent=2)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def write_file(path, content):
|
|
15
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
16
|
+
f.write(content)
|