Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

feat: mcp server launch with better interface (#2333)

JINO ROHIT92fdea78e148
diff --git a/camel/toolkits/base.py b/camel/toolkits/base.py
index 6ea8248be..31e5d92cc 100644
--- a/camel/toolkits/base.py
+++ b/camel/toolkits/base.py
@@ -12,7 +12,7 @@
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
-from typing import List, Optional
+from typing import List, Literal, Optional
from camel.toolkits import FunctionTool
from camel.utils import AgentOpsMeta, with_timeout
@@ -52,3 +52,11 @@ class BaseToolkit(metaclass=AgentOpsMeta):
representing the functions in the toolkit.
"""
raise NotImplementedError("Subclasses must implement this method.")
+
+ def run_mcp_server(self, mode: Literal["stdio", "sse"]) -> None:
+ r"""Run the MCP server in the specified mode.
+
+ Args:
+ mode (Literal["stdio", "sse"]): The mode to run the MCP server in.
+ """
+ self.mcp.run(mode)
diff --git a/docs/key_modules/tools.md b/docs/key_modules/tools.md
index 31c49ac2b..a54c1a88e 100644
--- a/docs/key_modules/tools.md
+++ b/docs/key_modules/tools.md
@@ -236,7 +236,7 @@ if __name__ == "__main__":
toolkit = ArxivToolkit(timeout=args.timeout)
# Run the toolkit as an MCP server
- toolkit.mcp.run(args.mode)
+ toolkit.run_mcp_server(mode=args.mode)
```
The server can be run in two modes:
diff --git a/examples/mcp_arxiv_toolkit/arxiv_toolkit_server.py b/examples/mcp_arxiv_toolkit/arxiv_toolkit_server.py
index bc4828ec4..c04631b90 100644
--- a/examples/mcp_arxiv_toolkit/arxiv_toolkit_server.py
+++ b/examples/mcp_arxiv_toolkit/arxiv_toolkit_server.py
@@ -38,4 +38,4 @@ if __name__ == "__main__":
toolkit = ArxivToolkit(timeout=args.timeout)
- toolkit.mcp.run(args.mode)
+ toolkit.run_mcp_server(mode=args.mode)