cmdbox 0.6.3.2__py3-none-any.whl → 0.6.4.1__py3-none-any.whl
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.
Potentially problematic release.
This version of cmdbox might be problematic. Click here for more details.
- cmdbox/app/app.py +22 -7
- cmdbox/app/common.py +9 -6
- cmdbox/app/commons/loghandler.py +101 -20
- cmdbox/app/commons/redis_client.py +1 -1
- cmdbox/app/edge.py +2 -4
- cmdbox/app/feature.py +1 -1
- cmdbox/app/features/cli/cmdbox_agent_mcp_client.py +175 -0
- cmdbox/app/features/cli/cmdbox_agent_mcp_proxy.py +96 -0
- cmdbox/app/features/cli/cmdbox_audit_createdb.py +224 -224
- cmdbox/app/features/cli/cmdbox_audit_delete.py +4 -4
- cmdbox/app/features/cli/cmdbox_audit_search.py +4 -4
- cmdbox/app/features/cli/cmdbox_audit_write.py +6 -8
- cmdbox/app/features/cli/cmdbox_client_file_copy.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_download.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_list.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_mkdir.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_move.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_remove.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_rmdir.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_file_upload.py +3 -3
- cmdbox/app/features/cli/cmdbox_client_http.py +7 -6
- cmdbox/app/features/cli/cmdbox_client_server_info.py +4 -4
- cmdbox/app/features/cli/cmdbox_cmd_list.py +4 -4
- cmdbox/app/features/cli/cmdbox_cmd_load.py +5 -5
- cmdbox/app/features/cli/cmdbox_edge_config.py +1 -1
- cmdbox/app/features/cli/cmdbox_edge_start.py +3 -3
- cmdbox/app/features/cli/cmdbox_mcp_client.py +174 -174
- cmdbox/app/features/cli/cmdbox_mcp_proxy.py +96 -96
- cmdbox/app/features/cli/cmdbox_server_list.py +3 -3
- cmdbox/app/features/cli/cmdbox_server_start.py +103 -103
- cmdbox/app/features/cli/cmdbox_server_stop.py +6 -6
- cmdbox/app/features/cli/cmdbox_tts_install.py +317 -0
- cmdbox/app/features/cli/cmdbox_tts_say.py +179 -0
- cmdbox/app/features/cli/cmdbox_tts_start.py +329 -0
- cmdbox/app/features/cli/cmdbox_tts_stop.py +108 -0
- cmdbox/app/features/cli/cmdbox_web_apikey_add.py +91 -91
- cmdbox/app/features/cli/cmdbox_web_apikey_del.py +91 -91
- cmdbox/app/features/cli/cmdbox_web_gencert.py +7 -7
- cmdbox/app/features/cli/cmdbox_web_genpass.py +168 -168
- cmdbox/app/features/cli/cmdbox_web_group_add.py +94 -94
- cmdbox/app/features/cli/cmdbox_web_group_del.py +87 -87
- cmdbox/app/features/cli/cmdbox_web_group_edit.py +94 -94
- cmdbox/app/features/cli/cmdbox_web_group_list.py +87 -87
- cmdbox/app/features/cli/cmdbox_web_start.py +236 -235
- cmdbox/app/features/cli/cmdbox_web_stop.py +72 -72
- cmdbox/app/features/cli/cmdbox_web_user_add.py +104 -104
- cmdbox/app/features/cli/cmdbox_web_user_del.py +87 -87
- cmdbox/app/features/cli/cmdbox_web_user_edit.py +104 -104
- cmdbox/app/features/cli/cmdbox_web_user_list.py +87 -87
- cmdbox/app/features/web/cmdbox_web_agent.py +16 -4
- cmdbox/app/features/web/cmdbox_web_get_cmd_choices.py +10 -2
- cmdbox/app/features/web/cmdbox_web_save_cmd.py +1 -0
- cmdbox/app/features/web/cmdbox_web_versions_used.py +4 -0
- cmdbox/app/filer.py +9 -9
- cmdbox/app/mcp.py +19 -8
- cmdbox/app/options.py +52 -47
- cmdbox/app/server.py +224 -224
- cmdbox/app/web.py +39 -17
- cmdbox/extensions/features.yml +7 -1
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_client_time.py +2 -2
- cmdbox/extensions/sample_project/sample/app/features/cli/sample_server_time.py +3 -3
- cmdbox/licenses/LICENSE_APScheduler_3_11_0_MIT_License.txt +19 -0
- cmdbox/licenses/LICENSE_SQLAlchemy_2_0_43_MIT.txt +19 -0
- cmdbox/licenses/LICENSE_Werkzeug_3_1_1_BSD_License.txt +28 -0
- cmdbox/licenses/LICENSE_absolufy-imports_0_3_1_MIT_License.txt +21 -0
- cmdbox/licenses/LICENSE_anyio_4_10_0_UNKNOWN.txt +20 -0
- cmdbox/licenses/{LICENSE_typer_0_16_0_MIT_License.txt → LICENSE_backoff_2_2_1_MIT_License.txt} +1 -1
- cmdbox/licenses/LICENSE_certifi_2025_8_3_Mozilla_Public_License_2_0-MPL_2_0.txt +20 -0
- cmdbox/licenses/LICENSE_charset-normalizer_3_4_3_MIT.txt +21 -0
- cmdbox/licenses/LICENSE_cryptography_45_0_6_Apache-2_0_OR_BSD-3-Clause.txt +3 -0
- cmdbox/licenses/LICENSE_cyclopts_3_22_5_Apache_Software_License.txt +201 -0
- cmdbox/licenses/LICENSE_fastapi-sso_0_18_0_MIT_License.txt +21 -0
- cmdbox/licenses/LICENSE_fastmcp_2_11_3_Apache_Software_License.txt +201 -0
- cmdbox/licenses/LICENSE_google-adk_1_9_0_Apache_Software_License.txt +202 -0
- cmdbox/licenses/LICENSE_google-genai_1_28_0_Apache_Software_License.txt +202 -0
- cmdbox/licenses/LICENSE_google-genai_1_29_0_Apache_Software_License.txt +202 -0
- cmdbox/licenses/LICENSE_greenlet_3_2_4_MIT_AND_Python-2_0.txt +30 -0
- cmdbox/licenses/LICENSE_isodate_0_7_2_BSD_License.txt +26 -0
- cmdbox/licenses/LICENSE_lazy-object-proxy_1_11_0_BSD_License.txt +20 -0
- cmdbox/licenses/LICENSE_litellm-enterprise_0_1_19_UNKNOWN.txt +37 -0
- cmdbox/licenses/LICENSE_litellm_1_75_5_post1_MIT_License.txt +26 -0
- cmdbox/licenses/LICENSE_markdown-it-py_4_0_0_MIT_License.txt +21 -0
- cmdbox/licenses/LICENSE_mcp_1_12_4_MIT_License.txt +21 -0
- cmdbox/licenses/LICENSE_multidict_6_6_4_Apache_License_2_0.txt +13 -0
- cmdbox/licenses/LICENSE_oauthlib_3_3_1_BSD-3-Clause.txt +27 -0
- cmdbox/licenses/LICENSE_openai_1_99_9_Apache_Software_License.txt +201 -0
- cmdbox/licenses/LICENSE_openapi-core_0_19_5_BSD_License.txt +29 -0
- cmdbox/licenses/LICENSE_openapi-schema-validator_0_6_3_BSD_License.txt +29 -0
- cmdbox/licenses/LICENSE_openapi-spec-validator_0_7_2_Apache_Software_License.txt +201 -0
- cmdbox/licenses/LICENSE_opentelemetry-api_1_36_0_UNKNOWN.txt +201 -0
- cmdbox/licenses/LICENSE_opentelemetry-sdk_1_36_0_UNKNOWN.txt +201 -0
- cmdbox/licenses/LICENSE_opentelemetry-semantic-conventions_0_57b0_UNKNOWN.txt +201 -0
- cmdbox/licenses/LICENSE_orjson_3_11_1_Apache_Software_License-MIT_License.txt +201 -0
- cmdbox/licenses/LICENSE_parse_1_20_2_MIT_License.txt +19 -0
- cmdbox/licenses/LICENSE_pathable_0_4_4_Apache_Software_License.txt +201 -0
- cmdbox/licenses/{LICENSE_pillow_11_2_1_UNKNOWN.txt → LICENSE_pillow_11_3_0_UNKNOWN.txt} +393 -3
- cmdbox/licenses/LICENSE_pyperclip_1_9_0_BSD_License.txt +27 -0
- cmdbox/licenses/LICENSE_redis_6_4_0_MIT_License.txt +21 -0
- cmdbox/licenses/LICENSE_rfc3339-validator_0_1_4_MIT_License.txt +22 -0
- cmdbox/licenses/LICENSE_rich-rst_1_3_1_MIT_License.txt +7 -0
- cmdbox/licenses/LICENSE_rpds-py_0_27_0_UNKNOWN.txt +19 -0
- cmdbox/licenses/{LICENSE_setuptools_65_5_0_MIT_License.txt → LICENSE_setuptools_80_9_0_UNKNOWN.txt} +0 -2
- cmdbox/licenses/LICENSE_sphinx-intl_2_3_2_UNKNOWN.txt +25 -0
- cmdbox/licenses/LICENSE_tenacity_9_1_2_Apache_Software_License.txt +202 -0
- cmdbox/licenses/LICENSE_tiktoken_0_11_0_MIT_License-Copyright-c-2022_OpenAI-Shantanu_Jain-Permission_is_hereby_granted-free_of_charge-to_any_per.txt +21 -0
- cmdbox/licenses/LICENSE_tokenizers_0_21_4_Apache_Software_License.txt +1 -0
- cmdbox/licenses/LICENSE_voicevox_core_0_16_0_MIT.txt +20 -0
- cmdbox/licenses/LICENSE_watchdog_6_0_0_Apache_Software_License.txt +16 -0
- cmdbox/licenses/{LICENSE_httptools_0_6_4_MIT_License.txt → LICENSE_wsproto_1_2_0_MIT_License.txt} +3 -3
- cmdbox/licenses/files.txt +69 -50
- cmdbox/logconf_cmdbox.yml +136 -0
- cmdbox/version.py +2 -2
- cmdbox/web/agent.html +16 -2
- cmdbox/web/assets/cmdbox/agent.js +226 -1
- cmdbox/web/assets/cmdbox/common.js +20 -25
- cmdbox/web/assets/cmdbox/svgicon.js +18 -0
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/METADATA +29 -20
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/RECORD +158 -118
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/WHEEL +1 -1
- cmdbox/config.yml +0 -3
- cmdbox/licenses/LICENSE_shellingham_1_5_4_ISC_License-ISCL.txt +0 -13
- cmdbox/licenses/LICENSE_watchfiles_1_1_0_MIT_License.txt +0 -21
- cmdbox/logconf_audit.yml +0 -43
- cmdbox/logconf_client.yml +0 -43
- cmdbox/logconf_edge.yml +0 -43
- cmdbox/logconf_gui.yml +0 -43
- cmdbox/logconf_mcp.yml +0 -43
- cmdbox/logconf_server.yml +0 -43
- cmdbox/logconf_web.yml +0 -43
- /cmdbox/licenses/{LICENSE_Authlib_1_6_0_BSD_License.txt → LICENSE_Authlib_1_6_1_BSD_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_SQLAlchemy_2_0_41_MIT.txt → LICENSE_SQLAlchemy_2_0_42_MIT.txt} +0 -0
- /cmdbox/licenses/{LICENSE_aiohttp_3_12_13_Apache-2_0.txt → LICENSE_aiohttp_3_12_15_Apache-2_0_AND_MIT.txt} +0 -0
- /cmdbox/licenses/{LICENSE_aiosignal_1_3_2_Apache_Software_License.txt → LICENSE_aiosignal_1_4_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_certifi_2025_6_15_Mozilla_Public_License_2_0-MPL_2_0.txt → LICENSE_certifi_2025_7_14_Mozilla_Public_License_2_0-MPL_2_0.txt} +0 -0
- /cmdbox/licenses/{LICENSE_cryptography_45_0_4_Apache-2_0_OR_BSD-3-Clause.txt → LICENSE_cryptography_45_0_5_Apache-2_0_OR_BSD-3-Clause.txt} +0 -0
- /cmdbox/licenses/{LICENSE_docstring_parser_0_16_MIT_License.txt → LICENSE_docstring_parser_0_17_0_MIT_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_fastapi_0_115_14_MIT_License.txt → LICENSE_fastapi_0_116_1_MIT_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_fastmcp_2_10_1_Apache_Software_License.txt → LICENSE_fastmcp_2_11_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_fsspec_2025_5_1_BSD_License.txt → LICENSE_fsspec_2025_7_0_BSD_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_google-adk_1_5_0_Apache_Software_License.txt → LICENSE_google-adk_1_10_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_google-api-python-client_2_174_0_Apache_Software_License.txt → LICENSE_google-api-python-client_2_177_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_huggingface-hub_0_33_1_Apache_Software_License.txt → LICENSE_google-api-python-client_2_178_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_google-cloud-aiplatform_1_100_0_Apache_2_0.txt → LICENSE_google-cloud-aiplatform_1_106_0_Apache_2_0.txt} +0 -0
- /cmdbox/licenses/{LICENSE_google-cloud-bigquery_3_34_0_Apache_Software_License.txt → LICENSE_google-cloud-aiplatform_1_108_0_Apache_2_0.txt} +0 -0
- /cmdbox/licenses/{LICENSE_google-genai_1_23_0_Apache_Software_License.txt → LICENSE_google-cloud-bigquery_3_35_1_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_grpcio-status_1_73_1_Apache_Software_License.txt → LICENSE_grpcio-status_1_74_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_grpcio_1_73_1_Apache_Software_License.txt → LICENSE_grpcio_1_74_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_opentelemetry-api_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_3_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_opentelemetry-sdk_1_34_1_Apache_Software_License.txt → LICENSE_huggingface-hub_0_34_4_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_opentelemetry-semantic-conventions_0_55b1_Apache_Software_License.txt → LICENSE_jsonschema-path_0_3_4_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_jsonschema_4_24_0_UNKNOWN.txt → LICENSE_jsonschema_4_25_0_UNKNOWN.txt} +0 -0
- /cmdbox/licenses/{LICENSE_litellm_1_73_6_MIT_License.txt → LICENSE_litellm_1_74_12_MIT_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_mcp_1_10_1_MIT_License.txt → LICENSE_mcp_1_12_3_MIT_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_multidict_6_6_2_Apache_License_2_0.txt → LICENSE_multidict_6_6_3_Apache_License_2_0.txt} +0 -0
- /cmdbox/licenses/{LICENSE_nh3_0_2_21_MIT.txt → LICENSE_nh3_0_3_0_MIT.txt} +0 -0
- /cmdbox/licenses/{LICENSE_numpy_2_3_1_BSD_License.txt → LICENSE_numpy_2_3_2_BSD_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_openai_1_93_0_Apache_Software_License.txt → LICENSE_openai_1_98_0_Apache_Software_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_tokenizers_0_21_2_Apache_Software_License.txt → LICENSE_pywin32_311_Python_Software_Foundation_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_regex_2024_11_6_Apache_Software_License.txt → LICENSE_regex_2025_7_34_UNKNOWN.txt} +0 -0
- /cmdbox/licenses/{LICENSE_rich_14_0_0_MIT_License.txt → LICENSE_rich_14_1_0_MIT_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_rpds-py_0_25_1_MIT.txt → LICENSE_rpds-py_0_26_0_MIT.txt} +0 -0
- /cmdbox/licenses/{LICENSE_sse-starlette_2_3_6_BSD_License.txt → LICENSE_sse-starlette_3_0_2_UNKNOWN.txt} +0 -0
- /cmdbox/licenses/{LICENSE_starlette_0_46_2_BSD_License.txt → LICENSE_starlette_0_47_2_BSD_License.txt} +0 -0
- /cmdbox/licenses/{LICENSE_typing_extensions_4_14_0_UNKNOWN.txt → LICENSE_typing_extensions_4_14_1_UNKNOWN.txt} +0 -0
- /cmdbox/licenses/{LICENSE_zope_event_5_1_Zope_Public_License.txt → LICENSE_zope_event_5_1_1_Zope_Public_License.txt} +0 -0
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/entry_points.txt +0 -0
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info/licenses}/LICENSE +0 -0
- {cmdbox-0.6.3.2.dist-info → cmdbox-0.6.4.1.dist-info}/top_level.txt +0 -0
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
from cmdbox.app import common, feature
|
|
2
|
-
from cmdbox.app.features.cli import cmdbox_web_start
|
|
3
|
-
from cmdbox.app.options import Options
|
|
4
|
-
from typing import Dict, Any, Tuple, List, Union
|
|
5
|
-
import argparse
|
|
6
|
-
import logging
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class McpClient(feature.UnsupportEdgeFeature):
|
|
10
|
-
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
-
"""
|
|
12
|
-
この機能のモードを返します
|
|
13
|
-
|
|
14
|
-
Returns:
|
|
15
|
-
Union[str, List[str]]: モード
|
|
16
|
-
"""
|
|
17
|
-
return 'mcp'
|
|
18
|
-
|
|
19
|
-
def get_cmd(self) -> str:
|
|
20
|
-
"""
|
|
21
|
-
この機能のコマンドを返します
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
str: コマンド
|
|
25
|
-
"""
|
|
26
|
-
return 'client'
|
|
27
|
-
|
|
28
|
-
def get_option(self):
|
|
29
|
-
"""
|
|
30
|
-
この機能のオプションを返します
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
Dict[str, Any]: オプション
|
|
34
|
-
"""
|
|
35
|
-
return dict(
|
|
36
|
-
use_redis=self.USE_REDIS_FALSE, nouse_webmode=True, use_agent=False,
|
|
37
|
-
description_ja="リモートMCPサーバーにリクエストを行うMCPクライアントを起動します。",
|
|
38
|
-
description_en="Starts an MCP client that makes requests to a remote MCP server.",
|
|
39
|
-
choice=[
|
|
40
|
-
dict(opt="mcpserver_name", type=Options.T_STR, default='mcpserver', required=True, multi=False, hide=False, choice=None,
|
|
41
|
-
description_ja="リモートMCPサーバーの名前を指定します。省略した場合は`mcpserver`となります。",
|
|
42
|
-
description_en="Specify the name of the MCP server. If omitted, it will be `mcpserver`.",),
|
|
43
|
-
dict(opt="mcpserver_url", type=Options.T_STR, default='http://localhost:8081/mcpsv/mcp', required=True, multi=False, hide=False, choice=None,
|
|
44
|
-
description_ja="リモートMCPサーバーのURLを指定します。省略した場合は`http://localhost:8081/mcpsv/mcp`となります。",
|
|
45
|
-
description_en="Specifies the URL of the remote MCP server. If omitted, it will be `http://localhost:8081/mcpsv/mcp`.",),
|
|
46
|
-
dict(opt="mcpserver_apikey", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
47
|
-
description_ja="リモートMCPサーバーのAPI Keyを指定します。",
|
|
48
|
-
description_en="Specify the API Key of the remote MCP server.",),
|
|
49
|
-
dict(opt="mcpserver_transport", type=Options.T_STR, default='streamable-http', required=True, multi=False, hide=False, choice=['', 'streamable-http', 'sse', 'http'],
|
|
50
|
-
description_ja="リモートMCPサーバーのトランスポートを指定します。省略した場合は`streamable-http`となります。",
|
|
51
|
-
description_en="Specifies the transport of the remote MCP server. If omitted, it is `streamable-http`.",),
|
|
52
|
-
dict(opt="operation", type=Options.T_STR, default='list_tools', required=True, multi=False, hide=False,
|
|
53
|
-
choice=['list_tools', 'call_tool', 'list_resources', 'read_resource', 'list_prompts', 'get_prompt'],
|
|
54
|
-
choice_show=dict(call_tool=['tool_name', 'tool_args', 'mcp_timeout',],
|
|
55
|
-
read_resource=['resource_url',],
|
|
56
|
-
get_prompt=['prompt_name', 'prompt_args']),
|
|
57
|
-
description_ja="リモートMCPサーバーに要求する操作を指定します。省略した場合は`list_tools`となります。",
|
|
58
|
-
description_en="Specifies the operations to request from the remote MCP server. If omitted, `list_tools` is used.",),
|
|
59
|
-
dict(opt="tool_name", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
60
|
-
description_ja="リモートMCPサーバーで実行するツールの名前を指定します。",
|
|
61
|
-
description_en="Specify the name of the tool to run on the remote MCP server."),
|
|
62
|
-
dict(opt="tool_args", type=Options.T_DICT, default=None, required=False, multi=True, hide=False, choice=None,
|
|
63
|
-
description_ja="リモートMCPサーバーで実行するツールの引数を指定します。",
|
|
64
|
-
description_en="Specify arguments for the tool to run on the remote MCP server."),
|
|
65
|
-
dict(opt="mcp_timeout", type=Options.T_INT, default="60", required=False, multi=False, hide=False, choice=None,
|
|
66
|
-
description_ja="リモートMCPサーバーの応答が返ってくるまでの最大待ち時間を指定します。",
|
|
67
|
-
description_en="Specifies the maximum time to wait for a response from the remote MCP server."),
|
|
68
|
-
dict(opt="resource_url", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
69
|
-
description_ja="リモートMCPサーバーから取得するリソースのURLを指定します。",
|
|
70
|
-
description_en="Specify the URL of the resource to retrieve from the remote MCP server."),
|
|
71
|
-
dict(opt="prompt_name", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
72
|
-
description_ja="リモートMCPサーバーから取得するプロンプトの名前を指定します。",
|
|
73
|
-
description_en="Specifies the name of the prompt to be retrieved from the remote MCP server."),
|
|
74
|
-
dict(opt="prompt_args", type=Options.T_DICT, default=None, required=False, multi=True, hide=False, choice=None,
|
|
75
|
-
description_ja="リモートMCPサーバーから取得するプロンプトの引数を指定します。",
|
|
76
|
-
description_en="Specifies prompt arguments to be retrieved from the remote MCP server."),
|
|
77
|
-
dict(opt="output_json", short="o", type=Options.T_FILE, default=None, required=False, multi=False, hide=True, choice=None, fileio="out",
|
|
78
|
-
description_ja="処理結果jsonの保存先ファイルを指定。",
|
|
79
|
-
description_en="Specify the destination file for saving the processing result json."),
|
|
80
|
-
dict(opt="output_json_append", short="a", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
|
|
81
|
-
description_ja="処理結果jsonファイルを追記保存します。",
|
|
82
|
-
description_en="Save the processing result json file by appending."),
|
|
83
|
-
dict(opt="stdout_log", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
|
|
84
|
-
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をConsole logに出力します。",
|
|
85
|
-
description_en="Available only in GUI mode. Outputs standard output during command execution to Console log."),
|
|
86
|
-
dict(opt="capture_stdout", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
|
|
87
|
-
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をキャプチャーし、実行結果画面に表示します。",
|
|
88
|
-
description_en="Available only in GUI mode. Captures standard output during command execution and displays it on the execution result screen."),
|
|
89
|
-
dict(opt="capture_maxsize", type=Options.T_INT, default=self.DEFAULT_CAPTURE_MAXSIZE, required=False, multi=False, hide=True, choice=None,
|
|
90
|
-
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力の最大キャプチャーサイズを指定します。",
|
|
91
|
-
description_en="Available only in GUI mode. Specifies the maximum capture size of standard output when executing commands."),
|
|
92
|
-
])
|
|
93
|
-
|
|
94
|
-
async def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
95
|
-
"""
|
|
96
|
-
この機能の実行を行います
|
|
97
|
-
|
|
98
|
-
Args:
|
|
99
|
-
logger (logging.Logger): ロガー
|
|
100
|
-
args (argparse.Namespace): 引数
|
|
101
|
-
tm (float): 実行開始時間
|
|
102
|
-
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
103
|
-
|
|
104
|
-
Returns:
|
|
105
|
-
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
106
|
-
"""
|
|
107
|
-
logger.info("apprun function has started.")
|
|
108
|
-
if not hasattr(args, 'mcpserver_name'):
|
|
109
|
-
args.mcpserver_name = 'mcpserver'
|
|
110
|
-
if not hasattr(args, 'mcpserver_url'):
|
|
111
|
-
args.mcpserver_url = 'http://localhost:8081/mcpsv/mcp'
|
|
112
|
-
if not hasattr(args, 'mcpserver_transport'):
|
|
113
|
-
args.mcpserver_transport = 'streamable-http'
|
|
114
|
-
if not hasattr(args, 'mcpserver_apikey'):
|
|
115
|
-
args.mcpserver_apikey = None
|
|
116
|
-
|
|
117
|
-
from fastmcp import Client
|
|
118
|
-
config = dict(
|
|
119
|
-
mcpServers=dict(
|
|
120
|
-
default=dict(
|
|
121
|
-
url=args.mcpserver_url,
|
|
122
|
-
transport=args.mcpserver_transport,
|
|
123
|
-
auth=args.mcpserver_apikey
|
|
124
|
-
)
|
|
125
|
-
)
|
|
126
|
-
)
|
|
127
|
-
try:
|
|
128
|
-
common.reset_logger('FastMCP.fastmcp.server.server')
|
|
129
|
-
client = Client(config)
|
|
130
|
-
if logger.level == logging.DEBUG:
|
|
131
|
-
logger.debug(f"Starting MCP client: {config}")
|
|
132
|
-
async with client:
|
|
133
|
-
if args.operation == 'list_tools':
|
|
134
|
-
result = await client.list_tools()
|
|
135
|
-
ret = dict(success=[r.__dict__ for r in result])
|
|
136
|
-
elif args.operation == 'call_tool':
|
|
137
|
-
if not args.tool_name:
|
|
138
|
-
raise ValueError("Tool name must be specified for 'call_tool' operation.")
|
|
139
|
-
if not args.tool_args:
|
|
140
|
-
args.tool_args = dict()
|
|
141
|
-
if not hasattr(args, 'mcp_timeout'):
|
|
142
|
-
args.mcp_timeout = 60
|
|
143
|
-
result = await client.call_tool(args.tool_name, arguments=args.tool_args, timeout=args.mcp_timeout)
|
|
144
|
-
ret = dict(success=result.__dict__)
|
|
145
|
-
elif args.operation == 'list_resources':
|
|
146
|
-
result = await client.list_resources()
|
|
147
|
-
ret = dict(success=[r.__dict__ for r in result])
|
|
148
|
-
elif args.operation == 'read_resource':
|
|
149
|
-
if not args.resource_url:
|
|
150
|
-
raise ValueError("Resource URL must be specified for 'read_resource' operation.")
|
|
151
|
-
result = await client.read_resource(args.resource_url)
|
|
152
|
-
ret = dict(success=result.__dict__)
|
|
153
|
-
elif args.operation == 'list_prompts':
|
|
154
|
-
result = await client.list_prompts()
|
|
155
|
-
ret = dict(success=[r.__dict__ for r in result])
|
|
156
|
-
elif args.operation == 'get_prompt':
|
|
157
|
-
if not args.prompt_name:
|
|
158
|
-
raise ValueError("Prompt name must be specified for 'get_prompt' operation.")
|
|
159
|
-
if not args.prompt_args:
|
|
160
|
-
args.prompt_args = dict()
|
|
161
|
-
result = await client.get_prompt(args.prompt_name, arguments=args.prompt_args)
|
|
162
|
-
ret = dict(success=result.__dict__)
|
|
163
|
-
else:
|
|
164
|
-
raise ValueError(f"Unknown operation: {args.operation}")
|
|
165
|
-
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
166
|
-
return self.
|
|
167
|
-
except Exception as e:
|
|
168
|
-
logger.setLevel(logging.ERROR)
|
|
169
|
-
for h in logger.handlers:
|
|
170
|
-
h.setLevel(logging.ERROR)
|
|
171
|
-
logger.error(f"Failed to start MCP proxy: {e}", exc_info=True)
|
|
172
|
-
msg = dict(warn=f"Failed to start MCP proxy: {e}")
|
|
173
|
-
common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
174
|
-
return self.RESP_ERROR, msg, None
|
|
1
|
+
from cmdbox.app import common, feature
|
|
2
|
+
from cmdbox.app.features.cli import cmdbox_web_start
|
|
3
|
+
from cmdbox.app.options import Options
|
|
4
|
+
from typing import Dict, Any, Tuple, List, Union
|
|
5
|
+
import argparse
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class McpClient(feature.UnsupportEdgeFeature):
|
|
10
|
+
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
+
"""
|
|
12
|
+
この機能のモードを返します
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
Union[str, List[str]]: モード
|
|
16
|
+
"""
|
|
17
|
+
return 'mcp'
|
|
18
|
+
|
|
19
|
+
def get_cmd(self) -> str:
|
|
20
|
+
"""
|
|
21
|
+
この機能のコマンドを返します
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
str: コマンド
|
|
25
|
+
"""
|
|
26
|
+
return 'client'
|
|
27
|
+
|
|
28
|
+
def get_option(self):
|
|
29
|
+
"""
|
|
30
|
+
この機能のオプションを返します
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Dict[str, Any]: オプション
|
|
34
|
+
"""
|
|
35
|
+
return dict(
|
|
36
|
+
use_redis=self.USE_REDIS_FALSE, nouse_webmode=True, use_agent=False,
|
|
37
|
+
description_ja="リモートMCPサーバーにリクエストを行うMCPクライアントを起動します。",
|
|
38
|
+
description_en="Starts an MCP client that makes requests to a remote MCP server.",
|
|
39
|
+
choice=[
|
|
40
|
+
dict(opt="mcpserver_name", type=Options.T_STR, default='mcpserver', required=True, multi=False, hide=False, choice=None,
|
|
41
|
+
description_ja="リモートMCPサーバーの名前を指定します。省略した場合は`mcpserver`となります。",
|
|
42
|
+
description_en="Specify the name of the MCP server. If omitted, it will be `mcpserver`.",),
|
|
43
|
+
dict(opt="mcpserver_url", type=Options.T_STR, default='http://localhost:8081/mcpsv/mcp', required=True, multi=False, hide=False, choice=None,
|
|
44
|
+
description_ja="リモートMCPサーバーのURLを指定します。省略した場合は`http://localhost:8081/mcpsv/mcp`となります。",
|
|
45
|
+
description_en="Specifies the URL of the remote MCP server. If omitted, it will be `http://localhost:8081/mcpsv/mcp`.",),
|
|
46
|
+
dict(opt="mcpserver_apikey", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
47
|
+
description_ja="リモートMCPサーバーのAPI Keyを指定します。",
|
|
48
|
+
description_en="Specify the API Key of the remote MCP server.",),
|
|
49
|
+
dict(opt="mcpserver_transport", type=Options.T_STR, default='streamable-http', required=True, multi=False, hide=False, choice=['', 'streamable-http', 'sse', 'http'],
|
|
50
|
+
description_ja="リモートMCPサーバーのトランスポートを指定します。省略した場合は`streamable-http`となります。",
|
|
51
|
+
description_en="Specifies the transport of the remote MCP server. If omitted, it is `streamable-http`.",),
|
|
52
|
+
dict(opt="operation", type=Options.T_STR, default='list_tools', required=True, multi=False, hide=False,
|
|
53
|
+
choice=['list_tools', 'call_tool', 'list_resources', 'read_resource', 'list_prompts', 'get_prompt'],
|
|
54
|
+
choice_show=dict(call_tool=['tool_name', 'tool_args', 'mcp_timeout',],
|
|
55
|
+
read_resource=['resource_url',],
|
|
56
|
+
get_prompt=['prompt_name', 'prompt_args']),
|
|
57
|
+
description_ja="リモートMCPサーバーに要求する操作を指定します。省略した場合は`list_tools`となります。",
|
|
58
|
+
description_en="Specifies the operations to request from the remote MCP server. If omitted, `list_tools` is used.",),
|
|
59
|
+
dict(opt="tool_name", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
60
|
+
description_ja="リモートMCPサーバーで実行するツールの名前を指定します。",
|
|
61
|
+
description_en="Specify the name of the tool to run on the remote MCP server."),
|
|
62
|
+
dict(opt="tool_args", type=Options.T_DICT, default=None, required=False, multi=True, hide=False, choice=None,
|
|
63
|
+
description_ja="リモートMCPサーバーで実行するツールの引数を指定します。",
|
|
64
|
+
description_en="Specify arguments for the tool to run on the remote MCP server."),
|
|
65
|
+
dict(opt="mcp_timeout", type=Options.T_INT, default="60", required=False, multi=False, hide=False, choice=None,
|
|
66
|
+
description_ja="リモートMCPサーバーの応答が返ってくるまでの最大待ち時間を指定します。",
|
|
67
|
+
description_en="Specifies the maximum time to wait for a response from the remote MCP server."),
|
|
68
|
+
dict(opt="resource_url", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
69
|
+
description_ja="リモートMCPサーバーから取得するリソースのURLを指定します。",
|
|
70
|
+
description_en="Specify the URL of the resource to retrieve from the remote MCP server."),
|
|
71
|
+
dict(opt="prompt_name", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
72
|
+
description_ja="リモートMCPサーバーから取得するプロンプトの名前を指定します。",
|
|
73
|
+
description_en="Specifies the name of the prompt to be retrieved from the remote MCP server."),
|
|
74
|
+
dict(opt="prompt_args", type=Options.T_DICT, default=None, required=False, multi=True, hide=False, choice=None,
|
|
75
|
+
description_ja="リモートMCPサーバーから取得するプロンプトの引数を指定します。",
|
|
76
|
+
description_en="Specifies prompt arguments to be retrieved from the remote MCP server."),
|
|
77
|
+
dict(opt="output_json", short="o", type=Options.T_FILE, default=None, required=False, multi=False, hide=True, choice=None, fileio="out",
|
|
78
|
+
description_ja="処理結果jsonの保存先ファイルを指定。",
|
|
79
|
+
description_en="Specify the destination file for saving the processing result json."),
|
|
80
|
+
dict(opt="output_json_append", short="a", type=Options.T_BOOL, default=False, required=False, multi=False, hide=True, choice=[True, False],
|
|
81
|
+
description_ja="処理結果jsonファイルを追記保存します。",
|
|
82
|
+
description_en="Save the processing result json file by appending."),
|
|
83
|
+
dict(opt="stdout_log", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
|
|
84
|
+
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をConsole logに出力します。",
|
|
85
|
+
description_en="Available only in GUI mode. Outputs standard output during command execution to Console log."),
|
|
86
|
+
dict(opt="capture_stdout", type=Options.T_BOOL, default=True, required=False, multi=False, hide=True, choice=[True, False],
|
|
87
|
+
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力をキャプチャーし、実行結果画面に表示します。",
|
|
88
|
+
description_en="Available only in GUI mode. Captures standard output during command execution and displays it on the execution result screen."),
|
|
89
|
+
dict(opt="capture_maxsize", type=Options.T_INT, default=self.DEFAULT_CAPTURE_MAXSIZE, required=False, multi=False, hide=True, choice=None,
|
|
90
|
+
description_ja="GUIモードでのみ使用可能です。コマンド実行時の標準出力の最大キャプチャーサイズを指定します。",
|
|
91
|
+
description_en="Available only in GUI mode. Specifies the maximum capture size of standard output when executing commands."),
|
|
92
|
+
])
|
|
93
|
+
|
|
94
|
+
async def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
95
|
+
"""
|
|
96
|
+
この機能の実行を行います
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
logger (logging.Logger): ロガー
|
|
100
|
+
args (argparse.Namespace): 引数
|
|
101
|
+
tm (float): 実行開始時間
|
|
102
|
+
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
106
|
+
"""
|
|
107
|
+
logger.info("apprun function has started.")
|
|
108
|
+
if not hasattr(args, 'mcpserver_name'):
|
|
109
|
+
args.mcpserver_name = 'mcpserver'
|
|
110
|
+
if not hasattr(args, 'mcpserver_url'):
|
|
111
|
+
args.mcpserver_url = 'http://localhost:8081/mcpsv/mcp'
|
|
112
|
+
if not hasattr(args, 'mcpserver_transport'):
|
|
113
|
+
args.mcpserver_transport = 'streamable-http'
|
|
114
|
+
if not hasattr(args, 'mcpserver_apikey'):
|
|
115
|
+
args.mcpserver_apikey = None
|
|
116
|
+
|
|
117
|
+
from fastmcp import Client
|
|
118
|
+
config = dict(
|
|
119
|
+
mcpServers=dict(
|
|
120
|
+
default=dict(
|
|
121
|
+
url=args.mcpserver_url,
|
|
122
|
+
transport=args.mcpserver_transport,
|
|
123
|
+
auth=args.mcpserver_apikey
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
try:
|
|
128
|
+
common.reset_logger('FastMCP.fastmcp.server.server')
|
|
129
|
+
client = Client(config)
|
|
130
|
+
if logger.level == logging.DEBUG:
|
|
131
|
+
logger.debug(f"Starting MCP client: {config}")
|
|
132
|
+
async with client:
|
|
133
|
+
if args.operation == 'list_tools':
|
|
134
|
+
result = await client.list_tools()
|
|
135
|
+
ret = dict(success=[r.__dict__ for r in result])
|
|
136
|
+
elif args.operation == 'call_tool':
|
|
137
|
+
if not args.tool_name:
|
|
138
|
+
raise ValueError("Tool name must be specified for 'call_tool' operation.")
|
|
139
|
+
if not args.tool_args:
|
|
140
|
+
args.tool_args = dict()
|
|
141
|
+
if not hasattr(args, 'mcp_timeout'):
|
|
142
|
+
args.mcp_timeout = 60
|
|
143
|
+
result = await client.call_tool(args.tool_name, arguments=args.tool_args, timeout=args.mcp_timeout)
|
|
144
|
+
ret = dict(success=result.__dict__)
|
|
145
|
+
elif args.operation == 'list_resources':
|
|
146
|
+
result = await client.list_resources()
|
|
147
|
+
ret = dict(success=[r.__dict__ for r in result])
|
|
148
|
+
elif args.operation == 'read_resource':
|
|
149
|
+
if not args.resource_url:
|
|
150
|
+
raise ValueError("Resource URL must be specified for 'read_resource' operation.")
|
|
151
|
+
result = await client.read_resource(args.resource_url)
|
|
152
|
+
ret = dict(success=result.__dict__)
|
|
153
|
+
elif args.operation == 'list_prompts':
|
|
154
|
+
result = await client.list_prompts()
|
|
155
|
+
ret = dict(success=[r.__dict__ for r in result])
|
|
156
|
+
elif args.operation == 'get_prompt':
|
|
157
|
+
if not args.prompt_name:
|
|
158
|
+
raise ValueError("Prompt name must be specified for 'get_prompt' operation.")
|
|
159
|
+
if not args.prompt_args:
|
|
160
|
+
args.prompt_args = dict()
|
|
161
|
+
result = await client.get_prompt(args.prompt_name, arguments=args.prompt_args)
|
|
162
|
+
ret = dict(success=result.__dict__)
|
|
163
|
+
else:
|
|
164
|
+
raise ValueError(f"Unknown operation: {args.operation}")
|
|
165
|
+
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
166
|
+
return self.RESP_SUCCESS, ret, None
|
|
167
|
+
except Exception as e:
|
|
168
|
+
logger.setLevel(logging.ERROR)
|
|
169
|
+
for h in logger.handlers:
|
|
170
|
+
h.setLevel(logging.ERROR)
|
|
171
|
+
logger.error(f"Failed to start MCP proxy: {e}", exc_info=True)
|
|
172
|
+
msg = dict(warn=f"Failed to start MCP proxy: {e}")
|
|
173
|
+
common.print_format(msg, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
174
|
+
return self.RESP_ERROR, msg, None
|
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
from cmdbox.app import common, feature
|
|
2
|
-
from cmdbox.app.features.cli import cmdbox_web_start
|
|
3
|
-
from cmdbox.app.options import Options
|
|
4
|
-
from typing import Dict, Any, Tuple, List, Union
|
|
5
|
-
import argparse
|
|
6
|
-
import logging
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class McpProxy(feature.UnsupportEdgeFeature):
|
|
10
|
-
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
-
"""
|
|
12
|
-
この機能のモードを返します
|
|
13
|
-
|
|
14
|
-
Returns:
|
|
15
|
-
Union[str, List[str]]: モード
|
|
16
|
-
"""
|
|
17
|
-
return 'mcp'
|
|
18
|
-
|
|
19
|
-
def get_cmd(self) -> str:
|
|
20
|
-
"""
|
|
21
|
-
この機能のコマンドを返します
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
str: コマンド
|
|
25
|
-
"""
|
|
26
|
-
return 'proxy'
|
|
27
|
-
|
|
28
|
-
def get_option(self):
|
|
29
|
-
"""
|
|
30
|
-
この機能のオプションを返します
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
Dict[str, Any]: オプション
|
|
34
|
-
"""
|
|
35
|
-
return dict(
|
|
36
|
-
use_redis=self.USE_REDIS_FALSE, nouse_webmode=False, use_agent=False,
|
|
37
|
-
description_ja="標準入力を受け付け、リモートMCPサーバーにリクエストを行うProxyサーバーを起動します。",
|
|
38
|
-
description_en="Starts a Proxy server that accepts standard input and makes requests to a remote MCP server.",
|
|
39
|
-
choice=[
|
|
40
|
-
dict(opt="mcpserver_name", type=Options.T_STR, default='mcpserver', required=True, multi=False, hide=False, choice=None,
|
|
41
|
-
description_ja="リモートMCPサーバーの名前を指定します。省略した場合は`mcpserver`となります。",
|
|
42
|
-
description_en="Specify the name of the MCP server. If omitted, it will be `mcpserver`.",),
|
|
43
|
-
dict(opt="mcpserver_url", type=Options.T_STR, default='http://localhost:8081/mcpsv/mcp', required=True, multi=False, hide=False, choice=None,
|
|
44
|
-
description_ja="リモートMCPサーバーのURLを指定します。省略した場合は`http://localhost:8081/mcpsv/mcp`となります。",
|
|
45
|
-
description_en="Specifies the URL of the remote MCP server. If omitted, it will be `http://localhost:8081/mcpsv/mcp`.",),
|
|
46
|
-
dict(opt="mcpserver_apikey", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
47
|
-
description_ja="リモートMCPサーバーのAPI Keyを指定します。",
|
|
48
|
-
description_en="Specify the API Key of the remote MCP server.",),
|
|
49
|
-
dict(opt="mcpserver_transport", type=Options.T_STR, default='streamable-http', required=True, multi=False, hide=False, choice=['', 'streamable-http', 'sse', 'http'],
|
|
50
|
-
description_ja="リモートMCPサーバーのトランスポートを指定します。省略した場合は`streamable-http`となります。",
|
|
51
|
-
description_en="Specifies the transport of the remote MCP server. If omitted, it is `streamable-http`.",),
|
|
52
|
-
])
|
|
53
|
-
|
|
54
|
-
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
55
|
-
"""
|
|
56
|
-
この機能の実行を行います
|
|
57
|
-
|
|
58
|
-
Args:
|
|
59
|
-
logger (logging.Logger): ロガー
|
|
60
|
-
args (argparse.Namespace): 引数
|
|
61
|
-
tm (float): 実行開始時間
|
|
62
|
-
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
63
|
-
|
|
64
|
-
Returns:
|
|
65
|
-
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
66
|
-
"""
|
|
67
|
-
if not hasattr(args, 'mcpserver_name'):
|
|
68
|
-
args.mcpserver_name = 'mcpserver'
|
|
69
|
-
if not hasattr(args, 'mcpserver_url'):
|
|
70
|
-
args.mcpserver_url = 'http://localhost:8081/mcpsv/mcp'
|
|
71
|
-
if not hasattr(args, 'mcpserver_transport'):
|
|
72
|
-
args.mcpserver_transport = 'streamable-http'
|
|
73
|
-
if not hasattr(args, 'mcpserver_apikey'):
|
|
74
|
-
args.mcpserver_apikey = None
|
|
75
|
-
|
|
76
|
-
from fastmcp import FastMCP
|
|
77
|
-
config = dict(
|
|
78
|
-
mcpServers=dict(
|
|
79
|
-
default=dict(
|
|
80
|
-
url=args.mcpserver_url,
|
|
81
|
-
transport=args.mcpserver_transport,
|
|
82
|
-
auth=args.mcpserver_apikey
|
|
83
|
-
)
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
try:
|
|
87
|
-
common.reset_logger('FastMCP.fastmcp.server.server')
|
|
88
|
-
proxy = FastMCP.as_proxy(config, name="Config-Based Proxy")
|
|
89
|
-
proxy.run()
|
|
90
|
-
except Exception as e:
|
|
91
|
-
logger.setLevel(logging.ERROR)
|
|
92
|
-
for h in logger.handlers:
|
|
93
|
-
h.setLevel(logging.ERROR)
|
|
94
|
-
logger.error(f"Failed to start MCP proxy: {e}", exc_info=True)
|
|
95
|
-
return self.RESP_ERROR, dict(warn=f"Failed to start MCP proxy: {e}"), None
|
|
96
|
-
return self.
|
|
1
|
+
from cmdbox.app import common, feature
|
|
2
|
+
from cmdbox.app.features.cli import cmdbox_web_start
|
|
3
|
+
from cmdbox.app.options import Options
|
|
4
|
+
from typing import Dict, Any, Tuple, List, Union
|
|
5
|
+
import argparse
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class McpProxy(feature.UnsupportEdgeFeature):
|
|
10
|
+
def get_mode(self) -> Union[str, List[str]]:
|
|
11
|
+
"""
|
|
12
|
+
この機能のモードを返します
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
Union[str, List[str]]: モード
|
|
16
|
+
"""
|
|
17
|
+
return 'mcp'
|
|
18
|
+
|
|
19
|
+
def get_cmd(self) -> str:
|
|
20
|
+
"""
|
|
21
|
+
この機能のコマンドを返します
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
str: コマンド
|
|
25
|
+
"""
|
|
26
|
+
return 'proxy'
|
|
27
|
+
|
|
28
|
+
def get_option(self):
|
|
29
|
+
"""
|
|
30
|
+
この機能のオプションを返します
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Dict[str, Any]: オプション
|
|
34
|
+
"""
|
|
35
|
+
return dict(
|
|
36
|
+
use_redis=self.USE_REDIS_FALSE, nouse_webmode=False, use_agent=False,
|
|
37
|
+
description_ja="標準入力を受け付け、リモートMCPサーバーにリクエストを行うProxyサーバーを起動します。",
|
|
38
|
+
description_en="Starts a Proxy server that accepts standard input and makes requests to a remote MCP server.",
|
|
39
|
+
choice=[
|
|
40
|
+
dict(opt="mcpserver_name", type=Options.T_STR, default='mcpserver', required=True, multi=False, hide=False, choice=None,
|
|
41
|
+
description_ja="リモートMCPサーバーの名前を指定します。省略した場合は`mcpserver`となります。",
|
|
42
|
+
description_en="Specify the name of the MCP server. If omitted, it will be `mcpserver`.",),
|
|
43
|
+
dict(opt="mcpserver_url", type=Options.T_STR, default='http://localhost:8081/mcpsv/mcp', required=True, multi=False, hide=False, choice=None,
|
|
44
|
+
description_ja="リモートMCPサーバーのURLを指定します。省略した場合は`http://localhost:8081/mcpsv/mcp`となります。",
|
|
45
|
+
description_en="Specifies the URL of the remote MCP server. If omitted, it will be `http://localhost:8081/mcpsv/mcp`.",),
|
|
46
|
+
dict(opt="mcpserver_apikey", type=Options.T_STR, default=None, required=False, multi=False, hide=False, choice=None,
|
|
47
|
+
description_ja="リモートMCPサーバーのAPI Keyを指定します。",
|
|
48
|
+
description_en="Specify the API Key of the remote MCP server.",),
|
|
49
|
+
dict(opt="mcpserver_transport", type=Options.T_STR, default='streamable-http', required=True, multi=False, hide=False, choice=['', 'streamable-http', 'sse', 'http'],
|
|
50
|
+
description_ja="リモートMCPサーバーのトランスポートを指定します。省略した場合は`streamable-http`となります。",
|
|
51
|
+
description_en="Specifies the transport of the remote MCP server. If omitted, it is `streamable-http`.",),
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
def apprun(self, logger:logging.Logger, args:argparse.Namespace, tm:float, pf:List[Dict[str, float]]=[]) -> Tuple[int, Dict[str, Any], Any]:
|
|
55
|
+
"""
|
|
56
|
+
この機能の実行を行います
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
logger (logging.Logger): ロガー
|
|
60
|
+
args (argparse.Namespace): 引数
|
|
61
|
+
tm (float): 実行開始時間
|
|
62
|
+
pf (List[Dict[str, float]]): 呼出元のパフォーマンス情報
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
Tuple[int, Dict[str, Any], Any]: 終了コード, 結果, オブジェクト
|
|
66
|
+
"""
|
|
67
|
+
if not hasattr(args, 'mcpserver_name'):
|
|
68
|
+
args.mcpserver_name = 'mcpserver'
|
|
69
|
+
if not hasattr(args, 'mcpserver_url'):
|
|
70
|
+
args.mcpserver_url = 'http://localhost:8081/mcpsv/mcp'
|
|
71
|
+
if not hasattr(args, 'mcpserver_transport'):
|
|
72
|
+
args.mcpserver_transport = 'streamable-http'
|
|
73
|
+
if not hasattr(args, 'mcpserver_apikey'):
|
|
74
|
+
args.mcpserver_apikey = None
|
|
75
|
+
|
|
76
|
+
from fastmcp import FastMCP
|
|
77
|
+
config = dict(
|
|
78
|
+
mcpServers=dict(
|
|
79
|
+
default=dict(
|
|
80
|
+
url=args.mcpserver_url,
|
|
81
|
+
transport=args.mcpserver_transport,
|
|
82
|
+
auth=args.mcpserver_apikey
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
try:
|
|
87
|
+
common.reset_logger('FastMCP.fastmcp.server.server')
|
|
88
|
+
proxy = FastMCP.as_proxy(config, name="Config-Based Proxy")
|
|
89
|
+
proxy.run()
|
|
90
|
+
except Exception as e:
|
|
91
|
+
logger.setLevel(logging.ERROR)
|
|
92
|
+
for h in logger.handlers:
|
|
93
|
+
h.setLevel(logging.ERROR)
|
|
94
|
+
logger.error(f"Failed to start MCP proxy: {e}", exc_info=True)
|
|
95
|
+
return self.RESP_ERROR, dict(warn=f"Failed to start MCP proxy: {e}"), None
|
|
96
|
+
return self.RESP_SUCCESS, dict(info="MCP proxy successfully."), None
|
|
@@ -33,7 +33,7 @@ class ServerList(feature.OneshotResultEdgeFeature):
|
|
|
33
33
|
Dict[str, Any]: オプション
|
|
34
34
|
"""
|
|
35
35
|
return dict(
|
|
36
|
-
use_redis=self.USE_REDIS_TRUE, nouse_webmode=False,
|
|
36
|
+
use_redis=self.USE_REDIS_TRUE, nouse_webmode=False, use_agent=True,
|
|
37
37
|
description_ja="起動中のサーバーの一覧を表示します。クライアント環境からの利用も可能です。",
|
|
38
38
|
description_en="Displays a list of running inference servers. Can also be used from the client environment.",
|
|
39
39
|
choice=[
|
|
@@ -84,5 +84,5 @@ class ServerList(feature.OneshotResultEdgeFeature):
|
|
|
84
84
|
ret = sv.list_server()
|
|
85
85
|
common.print_format(ret, args.format, tm, args.output_json, args.output_json_append, pf=pf)
|
|
86
86
|
if 'success' not in ret:
|
|
87
|
-
return
|
|
88
|
-
return
|
|
87
|
+
return self.RESP_WARN, ret, sv
|
|
88
|
+
return self.RESP_SUCCESS, ret, sv
|