mcp-use 1.3.9__tar.gz → 1.3.10__tar.gz
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 mcp-use might be problematic. Click here for more details.
- {mcp_use-1.3.9 → mcp_use-1.3.10}/PKG-INFO +15 -14
- {mcp_use-1.3.9 → mcp_use-1.3.10}/README.md +14 -13
- mcp_use-1.3.10/docs/agent/interactive-chat-patterns.mdx +272 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/agent/server-manager.mdx +52 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/docs.json +2 -1
- mcp_use-1.3.10/examples/simple_server_manager_use.py +112 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/__init__.py +6 -2
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/mcpagent.py +101 -17
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/remote.py +50 -19
- mcp_use-1.3.10/mcp_use/cli.py +581 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/logging.py +27 -12
- mcp_use-1.3.10/mcp_use/managers/base.py +36 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/server_manager.py +2 -1
- mcp_use-1.3.10/mcp_use/observability/__init__.py +9 -0
- mcp_use-1.3.10/mcp_use/observability/callbacks_manager.py +162 -0
- mcp_use-1.3.10/mcp_use/observability/laminar.py +42 -0
- mcp_use-1.3.10/mcp_use/observability/langfuse.py +59 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/pyproject.toml +4 -1
- mcp_use-1.3.9/mcp_use/observability/__init__.py +0 -8
- mcp_use-1.3.9/mcp_use/observability/laminar.py +0 -21
- mcp_use-1.3.9/mcp_use/observability/langfuse.py +0 -35
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.env.example +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/pull_request_template.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/release-drafter.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/changelog.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/publish.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/release-drafter.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/stale.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/tests.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.github/workflows/update-readme.yml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.gitignore +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/.pre-commit-config.yaml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/CHANGELOG.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/CLAUDE.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/CODE_OF_CONDUCT.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/CONTRIBUTING.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/LICENSE +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/README.md +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/advanced/building-custom-agents.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/advanced/logging.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/advanced/multi-server-setup.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/advanced/security.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/agent/agent-configuration.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/agent/llm-integration.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/agent/streaming.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/agent/structured-output.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/api-reference/adapters.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/api-reference/introduction.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/api-reference/mcpagent.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/api-reference/mcpclient.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/changelog.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/client-configuration.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/connection-types.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/direct-tool-calls.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/elicitation.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/logging.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/notifications.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/prompts.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/resources.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/sampling.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/sandbox.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/client/tools.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/community/showcase.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/development/observability.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/development/telemetry.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/development.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/favicon.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/fonts.css +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/getting-started/configuration.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/getting-started/index.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/getting-started/installation.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/getting-started/quickstart.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/01.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/02.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/configuration-dark.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/configuration-light.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/examples-dark.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/examples-light.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/hero-dark.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/hero-light.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/installation-dark.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/installation-light.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/quickstart-dark.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/images/quickstart-light.png +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/logo/dark.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/logo/light.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/logo/react.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/snippets/snippet-intro.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/snippets/youtube-embed.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/troubleshooting/common-issues.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/troubleshooting/connection-errors.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/docs/troubleshooting/performance.mdx +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/airbnb_mcp.json +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/airbnb_use.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/blender_use.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/browser_use.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/chat_example.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/direct_tool_call.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/filesystem_use.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/http_example.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/mcp_everything.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/multi_server_example.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/sandbox_everything.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/stream_example.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/examples/structured_output.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/adapters/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/adapters/base.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/adapters/langchain_adapter.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/base.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/prompts/system_prompt_builder.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/agents/prompts/templates.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/client.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/config.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/base.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/http.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/sandbox.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/stdio.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/utils.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/connectors/websocket.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/errors/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/errors/error_formatting.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/base_tool.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/connect_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/disconnect_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/get_active_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/list_servers_tool.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/managers/tools/search_tools.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/session.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/base.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/sse.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/stdio.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/streamable_http.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/task_managers/websocket.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/telemetry/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/telemetry/events.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/telemetry/telemetry.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/telemetry/utils.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/types/sandbox.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/mcp_use/utils.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/pytest.ini +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/ruff.toml +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/static/logo-gh.jpg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/static/logo_black.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/static/logo_white.svg +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/conftest.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/conftest.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/others/test_custom_streaming_integration.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_discovery.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_elicitation.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_logging.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_notifications.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_prompts.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_resources.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_sampling.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/primitives/test_tools.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/servers_for_testing/__init__.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/servers_for_testing/custom_streaming_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/servers_for_testing/primitive_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/servers_for_testing/simple_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/servers_for_testing/timeout_test_server.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/transports/test_sse.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/transports/test_stdio.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/integration/transports/test_streamable_http.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_client.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_config.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_http_connector.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_logging.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_sandbox_connector.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_search_tools_issue_138.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_session.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_stdio_connector.py +0 -0
- {mcp_use-1.3.9 → mcp_use-1.3.10}/tests/unit/test_websocket_connection_manager.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-use
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.10
|
|
4
4
|
Summary: MCP Library for LLMs
|
|
5
5
|
Author-email: Pietro Zullo <pietro.zullo@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -52,13 +52,14 @@ Description-Content-Type: text/markdown
|
|
|
52
52
|
</picture>
|
|
53
53
|
</div>
|
|
54
54
|
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
<div align="center">
|
|
56
|
+
<h2>🎉 <strong>We're LIVE on Product Hunt!</strong> 🎉</h2>
|
|
57
|
+
<p><strong>Support us today and help us reach #1!</strong></p>
|
|
58
|
+
<a href="https://www.producthunt.com/products/mcp-use?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-mcp-use" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1002629&theme=neutral&t=1754609432704" alt="mcp-use - Open source SDK and infra for MCP servers & agents | Product Hunt" style="width: 220px; height: 54px;" width="250" height="54" /></a>
|
|
59
|
+
<p>👆 <em>Click to upvote and leave a comment!</em></p>
|
|
60
|
+
</div>
|
|
58
61
|
|
|
59
|
-
<
|
|
60
|
-
<a href="https://www.producthunt.com/products/mcp-use?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-mcp-use" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1002629&theme=neutral&t=1754609432704" alt="mcp-use - Open source SDK and infra for MCP servers & agents | Product Hunt" style="width: 150px; height: 32px;" width="150" height="32" /></a>
|
|
61
|
-
</p>
|
|
62
|
+
<h1 align="center">🚀 Create MCP Clients and Agents</h1>
|
|
62
63
|
<p align="center">
|
|
63
64
|
<a href="https://github.com/pietrozullo/mcp-use/stargazers" alt="GitHub stars">
|
|
64
65
|
<img src="https://img.shields.io/github/stars/pietrozullo/mcp-use?style=social" /></a>
|
|
@@ -154,7 +155,7 @@ pip install mcp-use
|
|
|
154
155
|
Or install from source:
|
|
155
156
|
|
|
156
157
|
```bash
|
|
157
|
-
git clone https://github.com/
|
|
158
|
+
git clone https://github.com/mcp-use/mcp-use.git
|
|
158
159
|
cd mcp-use
|
|
159
160
|
pip install -e .
|
|
160
161
|
```
|
|
@@ -837,23 +838,23 @@ Thanks to all our amazing contributors!
|
|
|
837
838
|
</tr>
|
|
838
839
|
<tr>
|
|
839
840
|
<td><img src="https://avatars.githubusercontent.com/u/38653995?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/patchy631/ai-engineering-hub"><strong>patchy631/ai-engineering-hub</strong></a></td>
|
|
840
|
-
<td>⭐
|
|
841
|
+
<td>⭐ 17384</td>
|
|
841
842
|
</tr>
|
|
842
843
|
<tr>
|
|
843
844
|
<td><img src="https://avatars.githubusercontent.com/u/170207473?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/tavily-ai/meeting-prep-agent"><strong>tavily-ai/meeting-prep-agent</strong></a></td>
|
|
844
|
-
<td>⭐
|
|
845
|
+
<td>⭐ 131</td>
|
|
845
846
|
</tr>
|
|
846
847
|
<tr>
|
|
847
848
|
<td><img src="https://avatars.githubusercontent.com/u/164294848?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/buildfastwithai/gen-ai-experiments"><strong>buildfastwithai/gen-ai-experiments</strong></a></td>
|
|
848
|
-
<td>⭐
|
|
849
|
+
<td>⭐ 100</td>
|
|
849
850
|
</tr>
|
|
850
851
|
<tr>
|
|
851
852
|
<td><img src="https://avatars.githubusercontent.com/u/187057607?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/hud-evals/hud-python"><strong>hud-evals/hud-python</strong></a></td>
|
|
852
|
-
<td>⭐
|
|
853
|
+
<td>⭐ 78</td>
|
|
853
854
|
</tr>
|
|
854
855
|
<tr>
|
|
855
856
|
<td><img src="https://avatars.githubusercontent.com/u/20041231?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/krishnaik06/MCP-CRASH-Course"><strong>krishnaik06/MCP-CRASH-Course</strong></a></td>
|
|
856
|
-
<td>⭐
|
|
857
|
+
<td>⭐ 64</td>
|
|
857
858
|
</tr>
|
|
858
859
|
<tr>
|
|
859
860
|
<td><img src="https://avatars.githubusercontent.com/u/54944174?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/larksuite/lark-samples"><strong>larksuite/lark-samples</strong></a></td>
|
|
@@ -869,7 +870,7 @@ Thanks to all our amazing contributors!
|
|
|
869
870
|
</tr>
|
|
870
871
|
<tr>
|
|
871
872
|
<td><img src="https://avatars.githubusercontent.com/u/201161342?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/autometa-dev/whatsapp-mcp-voice-agent"><strong>autometa-dev/whatsapp-mcp-voice-agent</strong></a></td>
|
|
872
|
-
<td>⭐
|
|
873
|
+
<td>⭐ 23</td>
|
|
873
874
|
</tr>
|
|
874
875
|
<tr>
|
|
875
876
|
<td><img src="https://avatars.githubusercontent.com/u/100749943?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/Deniscartin/mcp-cli"><strong>Deniscartin/mcp-cli</strong></a></td>
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
</picture>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<div align="center">
|
|
11
|
+
<h2>🎉 <strong>We're LIVE on Product Hunt!</strong> 🎉</h2>
|
|
12
|
+
<p><strong>Support us today and help us reach #1!</strong></p>
|
|
13
|
+
<a href="https://www.producthunt.com/products/mcp-use?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-mcp-use" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1002629&theme=neutral&t=1754609432704" alt="mcp-use - Open source SDK and infra for MCP servers & agents | Product Hunt" style="width: 220px; height: 54px;" width="250" height="54" /></a>
|
|
14
|
+
<p>👆 <em>Click to upvote and leave a comment!</em></p>
|
|
15
|
+
</div>
|
|
13
16
|
|
|
14
|
-
<
|
|
15
|
-
<a href="https://www.producthunt.com/products/mcp-use?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-mcp-use" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1002629&theme=neutral&t=1754609432704" alt="mcp-use - Open source SDK and infra for MCP servers & agents | Product Hunt" style="width: 150px; height: 32px;" width="150" height="32" /></a>
|
|
16
|
-
</p>
|
|
17
|
+
<h1 align="center">🚀 Create MCP Clients and Agents</h1>
|
|
17
18
|
<p align="center">
|
|
18
19
|
<a href="https://github.com/pietrozullo/mcp-use/stargazers" alt="GitHub stars">
|
|
19
20
|
<img src="https://img.shields.io/github/stars/pietrozullo/mcp-use?style=social" /></a>
|
|
@@ -109,7 +110,7 @@ pip install mcp-use
|
|
|
109
110
|
Or install from source:
|
|
110
111
|
|
|
111
112
|
```bash
|
|
112
|
-
git clone https://github.com/
|
|
113
|
+
git clone https://github.com/mcp-use/mcp-use.git
|
|
113
114
|
cd mcp-use
|
|
114
115
|
pip install -e .
|
|
115
116
|
```
|
|
@@ -792,23 +793,23 @@ Thanks to all our amazing contributors!
|
|
|
792
793
|
</tr>
|
|
793
794
|
<tr>
|
|
794
795
|
<td><img src="https://avatars.githubusercontent.com/u/38653995?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/patchy631/ai-engineering-hub"><strong>patchy631/ai-engineering-hub</strong></a></td>
|
|
795
|
-
<td>⭐
|
|
796
|
+
<td>⭐ 17384</td>
|
|
796
797
|
</tr>
|
|
797
798
|
<tr>
|
|
798
799
|
<td><img src="https://avatars.githubusercontent.com/u/170207473?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/tavily-ai/meeting-prep-agent"><strong>tavily-ai/meeting-prep-agent</strong></a></td>
|
|
799
|
-
<td>⭐
|
|
800
|
+
<td>⭐ 131</td>
|
|
800
801
|
</tr>
|
|
801
802
|
<tr>
|
|
802
803
|
<td><img src="https://avatars.githubusercontent.com/u/164294848?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/buildfastwithai/gen-ai-experiments"><strong>buildfastwithai/gen-ai-experiments</strong></a></td>
|
|
803
|
-
<td>⭐
|
|
804
|
+
<td>⭐ 100</td>
|
|
804
805
|
</tr>
|
|
805
806
|
<tr>
|
|
806
807
|
<td><img src="https://avatars.githubusercontent.com/u/187057607?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/hud-evals/hud-python"><strong>hud-evals/hud-python</strong></a></td>
|
|
807
|
-
<td>⭐
|
|
808
|
+
<td>⭐ 78</td>
|
|
808
809
|
</tr>
|
|
809
810
|
<tr>
|
|
810
811
|
<td><img src="https://avatars.githubusercontent.com/u/20041231?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/krishnaik06/MCP-CRASH-Course"><strong>krishnaik06/MCP-CRASH-Course</strong></a></td>
|
|
811
|
-
<td>⭐
|
|
812
|
+
<td>⭐ 64</td>
|
|
812
813
|
</tr>
|
|
813
814
|
<tr>
|
|
814
815
|
<td><img src="https://avatars.githubusercontent.com/u/54944174?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/larksuite/lark-samples"><strong>larksuite/lark-samples</strong></a></td>
|
|
@@ -824,7 +825,7 @@ Thanks to all our amazing contributors!
|
|
|
824
825
|
</tr>
|
|
825
826
|
<tr>
|
|
826
827
|
<td><img src="https://avatars.githubusercontent.com/u/201161342?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/autometa-dev/whatsapp-mcp-voice-agent"><strong>autometa-dev/whatsapp-mcp-voice-agent</strong></a></td>
|
|
827
|
-
<td>⭐
|
|
828
|
+
<td>⭐ 23</td>
|
|
828
829
|
</tr>
|
|
829
830
|
<tr>
|
|
830
831
|
<td><img src="https://avatars.githubusercontent.com/u/100749943?s=40&v=4" width="20" height="20" style="vertical-align: middle; margin-right: 8px;"> <a href="https://github.com/Deniscartin/mcp-cli"><strong>Deniscartin/mcp-cli</strong></a></td>
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Interactive Chat Patterns"
|
|
3
|
+
description: "Create interactive chat interfaces with persistent conversation memory"
|
|
4
|
+
icon: "message-circle"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Building a chat loop
|
|
8
|
+
|
|
9
|
+
With mcp-use you can build interactive interface where users can have conversations with
|
|
10
|
+
your `MCPAgent`, maintaining context and memory across multiple queries.
|
|
11
|
+
|
|
12
|
+
## Basic chat loop
|
|
13
|
+
Here's a basic chat-loop with conversation memory enabled:
|
|
14
|
+
```python chat_loop.py
|
|
15
|
+
import asyncio
|
|
16
|
+
from dotenv import load_dotenv
|
|
17
|
+
from langchain_openai import ChatOpenAI
|
|
18
|
+
from mcp_use import MCPAgent, MCPClient
|
|
19
|
+
|
|
20
|
+
async def basic_chat_loop():
|
|
21
|
+
"""Simple console chat loop with MCPAgent"""
|
|
22
|
+
# Load environment variables
|
|
23
|
+
load_dotenv()
|
|
24
|
+
|
|
25
|
+
# MCP server configuration
|
|
26
|
+
config = {
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"playwright": {
|
|
29
|
+
"command": "npx",
|
|
30
|
+
"args": ["@playwright/mcp@latest"],
|
|
31
|
+
"env": {"DISPLAY": ":1"}
|
|
32
|
+
},
|
|
33
|
+
"filesystem": {
|
|
34
|
+
"command": "npx",
|
|
35
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# Create client and agent
|
|
41
|
+
client = MCPClient.from_dict(config)
|
|
42
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
43
|
+
|
|
44
|
+
agent = MCPAgent(llm=llm,
|
|
45
|
+
client=client,
|
|
46
|
+
memory_enabled=True, # Enable memory to track conversation history
|
|
47
|
+
max_steps=20)
|
|
48
|
+
|
|
49
|
+
# Some initial messages
|
|
50
|
+
print("🤖 MCP Agent Chat")
|
|
51
|
+
print("Type 'quit/exit' to exit the chat.")
|
|
52
|
+
print("Type 'clear' to clear conversation history")
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
while True:
|
|
56
|
+
user_input = input("\nYou: ")
|
|
57
|
+
|
|
58
|
+
if user_input.lower() in ['quit', 'exit']:
|
|
59
|
+
print("👋 Goodbye!")
|
|
60
|
+
break
|
|
61
|
+
|
|
62
|
+
if user_input.lower() == 'clear':
|
|
63
|
+
agent.clear_conversation_history()
|
|
64
|
+
print("🧹 Conversation history cleared.")
|
|
65
|
+
continue
|
|
66
|
+
|
|
67
|
+
# Skip empty messages
|
|
68
|
+
if not user_input:
|
|
69
|
+
continue
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
print("\n🤖 Assistant: ", end="", flush=True)
|
|
73
|
+
response = await agent.run(user_input)
|
|
74
|
+
print(response)
|
|
75
|
+
except KeyboardInterrupt: # Handle keyboard interrupt
|
|
76
|
+
print("\n\n⏸️ Interrupted by user")
|
|
77
|
+
break
|
|
78
|
+
except Exception as e:
|
|
79
|
+
print(f"\n❌ Error: {e}")
|
|
80
|
+
print("Please try again or type 'exit' to quit.")
|
|
81
|
+
finally:
|
|
82
|
+
await client.close_all_sessions()
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
asyncio.run(basic_chat_loop())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Streaming Chat Loop
|
|
89
|
+
|
|
90
|
+
Here's a chat loop with streaming responses enabled:
|
|
91
|
+
|
|
92
|
+
```python chat_loop_streaming.py
|
|
93
|
+
import asyncio
|
|
94
|
+
from dotenv import load_dotenv
|
|
95
|
+
from langchain_openai import ChatOpenAI
|
|
96
|
+
from mcp_use import MCPAgent, MCPClient
|
|
97
|
+
|
|
98
|
+
async def streaming_chat_loop():
|
|
99
|
+
"""Chat loop with streaming responses with MCPAgent"""
|
|
100
|
+
# Load environment variables
|
|
101
|
+
load_dotenv()
|
|
102
|
+
|
|
103
|
+
# MCP server configuration
|
|
104
|
+
config = {
|
|
105
|
+
"mcpServers": {
|
|
106
|
+
"playwright": {
|
|
107
|
+
"command": "npx",
|
|
108
|
+
"args": ["@playwright/mcp@latest"],
|
|
109
|
+
"env": {"DISPLAY": ":1"}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Create client and agent
|
|
115
|
+
client = MCPClient.from_dict(config)
|
|
116
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
117
|
+
|
|
118
|
+
agent = MCPAgent(llm=llm,
|
|
119
|
+
client=client,
|
|
120
|
+
memory_enabled=True, # Enable memory to track conversation history
|
|
121
|
+
max_steps=20)
|
|
122
|
+
|
|
123
|
+
# Some initial messages
|
|
124
|
+
print("🤖 MCP Agent Chat (Streaming)")
|
|
125
|
+
print("Type 'quit/exit' to exit the chat.")
|
|
126
|
+
print("Type 'clear' to clear conversation history")
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
while True:
|
|
130
|
+
user_input = input("\nYou: ")
|
|
131
|
+
|
|
132
|
+
if user_input.lower() in ['quit', 'exit']:
|
|
133
|
+
print("👋 Goodbye!")
|
|
134
|
+
break
|
|
135
|
+
|
|
136
|
+
if user_input.lower() == 'clear':
|
|
137
|
+
agent.clear_conversation_history()
|
|
138
|
+
print("🧹 Conversation history cleared.")
|
|
139
|
+
continue
|
|
140
|
+
|
|
141
|
+
if not user_input: # Skip empty messages
|
|
142
|
+
continue
|
|
143
|
+
|
|
144
|
+
try:
|
|
145
|
+
print("\n🤖 Assistant: ", end="", flush=True)
|
|
146
|
+
|
|
147
|
+
# Stream the response
|
|
148
|
+
async for chunk in agent.stream(user_input):
|
|
149
|
+
print(chunk, end="", flush=True)
|
|
150
|
+
print()
|
|
151
|
+
except KeyboardInterrupt: # Handle keyboard interrupt
|
|
152
|
+
print("\n\n⏸️ Interrupted by user")
|
|
153
|
+
break
|
|
154
|
+
except Exception as e:
|
|
155
|
+
print(f"\n❌ Error: {e}")
|
|
156
|
+
print("Please try again or type 'exit' to quit.")
|
|
157
|
+
finally:
|
|
158
|
+
await client.close_all_sessions()
|
|
159
|
+
|
|
160
|
+
if __name__ == "__main__":
|
|
161
|
+
asyncio.run(streaming_chat_loop())
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Chat Loop with Structured I/O
|
|
165
|
+
|
|
166
|
+
It's possible to create a chat loop that can handle both natural language and structured inputs, allowing users to request specific tasks or analyses in a structured format. Here's an example of how to implement this:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
import asyncio
|
|
170
|
+
from dotenv import load_dotenv
|
|
171
|
+
from pydantic import BaseModel, Field
|
|
172
|
+
from langchain_openai import ChatOpenAI
|
|
173
|
+
from mcp_use import MCPAgent, MCPClient
|
|
174
|
+
from typing import Optional
|
|
175
|
+
|
|
176
|
+
class TaskRequest(BaseModel):
|
|
177
|
+
task_type: Optional[str] = Field(description="The type of task to perform")
|
|
178
|
+
description: Optional[str] = Field(description="Detailed description of the task")
|
|
179
|
+
priority: Optional[str] = Field(description="Priority level: low, medium, high")
|
|
180
|
+
|
|
181
|
+
async def structured_chat_loop():
|
|
182
|
+
"""Chat loop that can handle both natural language and structured inputs."""
|
|
183
|
+
# Load environment variables
|
|
184
|
+
load_dotenv()
|
|
185
|
+
|
|
186
|
+
# MCP server configuration
|
|
187
|
+
config = {
|
|
188
|
+
"mcpServers": {
|
|
189
|
+
"playwright": {
|
|
190
|
+
"command": "npx",
|
|
191
|
+
"args": ["@playwright/mcp@latest"],
|
|
192
|
+
"env": {"DISPLAY": ":1"}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
# Create client and agent
|
|
198
|
+
client = MCPClient.from_dict(config)
|
|
199
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
200
|
+
|
|
201
|
+
agent = MCPAgent(
|
|
202
|
+
llm=llm,
|
|
203
|
+
client=client,
|
|
204
|
+
memory_enabled=True, # Enable memory to track conversation history
|
|
205
|
+
max_steps=20
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# Initial messages
|
|
209
|
+
print("🤖 MCP Agent Chat (Structured)")
|
|
210
|
+
print("You can chat naturally or request structured task analysis")
|
|
211
|
+
print("Type 'task' to create a structured task request")
|
|
212
|
+
|
|
213
|
+
try:
|
|
214
|
+
while True:
|
|
215
|
+
user_input = input("\nYou: ")
|
|
216
|
+
if user_input.lower() in ['exit', 'quit']:
|
|
217
|
+
print("👋 Goodbye!")
|
|
218
|
+
break
|
|
219
|
+
|
|
220
|
+
try:
|
|
221
|
+
if user_input.lower() == 'task':
|
|
222
|
+
print("\n📋 Creating structured task...")
|
|
223
|
+
task_description = input("Describe your task: ")
|
|
224
|
+
|
|
225
|
+
task: TaskRequest = await agent.run(
|
|
226
|
+
f"Analyze a task with the following description: {task_description}",
|
|
227
|
+
output_schema=TaskRequest
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# Print task analysis
|
|
231
|
+
print(f"\n✅ Task Analysis:")
|
|
232
|
+
print(f"• Type: {task.task_type}")
|
|
233
|
+
print(f"• Description: {task.description}")
|
|
234
|
+
print(f"• Priority: {task.priority or 'low'}")
|
|
235
|
+
|
|
236
|
+
proceed = input("\nDo you want to proceed with this task? (y/n)")
|
|
237
|
+
if proceed.lower() == 'y':
|
|
238
|
+
response = await agent.run(
|
|
239
|
+
f"Execute the following task: {task.description}"
|
|
240
|
+
)
|
|
241
|
+
print(f"\n🤖 Assistant: {response}")
|
|
242
|
+
else:
|
|
243
|
+
# Regular conversation
|
|
244
|
+
response = await agent.run(user_input)
|
|
245
|
+
print(f"\n🤖 Assistant: {response}")
|
|
246
|
+
except KeyboardInterrupt:
|
|
247
|
+
print("\n👋 Goodbye!")
|
|
248
|
+
break
|
|
249
|
+
except Exception as e:
|
|
250
|
+
print(f"❌ Error: {e}")
|
|
251
|
+
print("Please try again or type 'exit' to quit.")
|
|
252
|
+
|
|
253
|
+
finally:
|
|
254
|
+
await client.close_all_sessions()
|
|
255
|
+
|
|
256
|
+
if __name__ == "__main__":
|
|
257
|
+
asyncio.run(structured_chat_loop())
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Next Steps
|
|
261
|
+
|
|
262
|
+
<CardGroup cols={3}>
|
|
263
|
+
<Card title="Agent Configuration" icon="cloud" href="/agent/agent-configuration">
|
|
264
|
+
Learn more about configuring agents for optimal streaming performance
|
|
265
|
+
</Card>
|
|
266
|
+
<Card title="Multi-Server Setup" icon="server" href="/advanced/multi-server-setup">
|
|
267
|
+
Stream output from agents using multiple MCP servers
|
|
268
|
+
</Card>
|
|
269
|
+
<Card title="Security Best Practices" icon="shield" href="/advanced/security">
|
|
270
|
+
Learn how to secure your MCP deployments
|
|
271
|
+
</Card>
|
|
272
|
+
</CardGroup>
|
|
@@ -71,6 +71,7 @@ agent = MCPAgent(
|
|
|
71
71
|
)
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
|
|
74
75
|
## 🔍 Tool Discovery Flow
|
|
75
76
|
|
|
76
77
|
|
|
@@ -213,3 +214,54 @@ if __name__ == "__main__":
|
|
|
213
214
|
```
|
|
214
215
|
|
|
215
216
|
The Server Manager transforms your MCP agent from a static tool user into an intelligent, adaptive assistant that can dynamically discover and utilize the perfect tools for any task! 🚀
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## Bring Your Own Server Manager
|
|
221
|
+
|
|
222
|
+
For ultimate control, you can create your own server manager. By implementing the `BaseServerManager` abstract class, you can define custom logic for tool discovery, dynamic tool creation, or integration with other systems. The server manager's primary role is to provide tools **to the agent**. These can be management tools for connecting to external MCP servers, or, as shown below, custom tools that operate entirely within the agent's environment without needing an external server.
|
|
223
|
+
|
|
224
|
+
Here’s a minimal example of a custom server manager that provides a single, hard-coded tool directly to the agent.
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
import asyncio
|
|
228
|
+
from mcp_use.agents import MCPAgent
|
|
229
|
+
from mcp_use.managers.base import BaseServerManager
|
|
230
|
+
from langchain_core.tools import BaseTool
|
|
231
|
+
from langchain_openai import ChatOpenAI
|
|
232
|
+
from pydantic import BaseModel
|
|
233
|
+
|
|
234
|
+
# 1. Define a custom tool
|
|
235
|
+
class HelloWorldTool(BaseTool):
|
|
236
|
+
"""A simple tool that returns a greeting."""
|
|
237
|
+
name: str = "hello_world"
|
|
238
|
+
description: str = "Returns 'Hello, World!'"
|
|
239
|
+
args_schema: type[BaseModel] | None = None
|
|
240
|
+
def _run(self) -> str: return "Hello, World!"
|
|
241
|
+
async def _arun(self) -> str: return "Hello, World!"
|
|
242
|
+
|
|
243
|
+
# 2. Implement the BaseServerManager interface
|
|
244
|
+
class SimpleServerManager(BaseServerManager):
|
|
245
|
+
"""A minimal server manager with one tool."""
|
|
246
|
+
def __init__(self):
|
|
247
|
+
self._tools = [HelloWorldTool()]
|
|
248
|
+
async def initialize(self) -> None: pass
|
|
249
|
+
@property
|
|
250
|
+
def tools(self) -> list[BaseTool]: return self._tools
|
|
251
|
+
def has_tool_changes(self, current_tool_names: set[str]) -> bool:
|
|
252
|
+
return {tool.name for tool in self.tools} != current_tool_names
|
|
253
|
+
|
|
254
|
+
# 3. Pass your custom manager to the agent
|
|
255
|
+
async def useCustomManager():
|
|
256
|
+
agent = MCPAgent(
|
|
257
|
+
llm=ChatOpenAI(model="gpt-4o"),
|
|
258
|
+
use_server_manager=True,
|
|
259
|
+
server_manager=SimpleServerManager(),
|
|
260
|
+
)
|
|
261
|
+
# The agent now has access to your custom tool
|
|
262
|
+
result = await agent.run("Use the hello_world tool")
|
|
263
|
+
print(result) #> "Hello, World!"
|
|
264
|
+
await agent.close()
|
|
265
|
+
|
|
266
|
+
asyncio.run(useCustomManager())
|
|
267
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from langchain_core.tools import BaseTool
|
|
6
|
+
from langchain_openai import ChatOpenAI
|
|
7
|
+
from pydantic import BaseModel
|
|
8
|
+
|
|
9
|
+
from mcp_use.agents.mcpagent import MCPAgent
|
|
10
|
+
|
|
11
|
+
# Add the project root to the Python path
|
|
12
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
13
|
+
from mcp_use.managers.base import BaseServerManager
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DynamicTool(BaseTool):
|
|
17
|
+
"""A tool that is created dynamically."""
|
|
18
|
+
|
|
19
|
+
name: str
|
|
20
|
+
description: str
|
|
21
|
+
args_schema: type[BaseModel] | None = None
|
|
22
|
+
|
|
23
|
+
def _run(self) -> str:
|
|
24
|
+
return f"Hello from {self.name}!"
|
|
25
|
+
|
|
26
|
+
async def _arun(self) -> str:
|
|
27
|
+
return f"Hello from {self.name}!"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class HelloWorldTool(BaseTool):
|
|
31
|
+
"""A simple tool that returns a greeting and adds a new tool."""
|
|
32
|
+
|
|
33
|
+
name: str = "hello_world"
|
|
34
|
+
description: str = "Returns the string 'Hello, World!' and adds a new dynamic tool."
|
|
35
|
+
args_schema: type[BaseModel] | None = None
|
|
36
|
+
server_manager: "SimpleServerManager"
|
|
37
|
+
|
|
38
|
+
def _run(self) -> str:
|
|
39
|
+
new_tool = DynamicTool(
|
|
40
|
+
name=f"dynamic_tool_{len(self.server_manager.tools)}", description="A dynamically created tool."
|
|
41
|
+
)
|
|
42
|
+
self.server_manager.add_tool(new_tool)
|
|
43
|
+
return "Hello, World! I've added a new tool. You can use it now."
|
|
44
|
+
|
|
45
|
+
async def _arun(self) -> str:
|
|
46
|
+
new_tool = DynamicTool(
|
|
47
|
+
name=f"dynamic_tool_{len(self.server_manager.tools)}", description="A dynamically created tool."
|
|
48
|
+
)
|
|
49
|
+
self.server_manager.add_tool(new_tool)
|
|
50
|
+
return "Hello, World! I've added a new tool. You can use it now."
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class SimpleServerManager(BaseServerManager):
|
|
54
|
+
"""A simple server manager that provides a HelloWorldTool."""
|
|
55
|
+
|
|
56
|
+
def __init__(self):
|
|
57
|
+
self._tools: list[BaseTool] = []
|
|
58
|
+
self._initialized = False
|
|
59
|
+
# Pass a reference to the server manager to the tool
|
|
60
|
+
self._tools.append(HelloWorldTool(server_manager=self))
|
|
61
|
+
|
|
62
|
+
def add_tool(self, tool: BaseTool):
|
|
63
|
+
self._tools.append(tool)
|
|
64
|
+
|
|
65
|
+
async def initialize(self) -> None:
|
|
66
|
+
self._initialized = True
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def tools(self) -> list[BaseTool]:
|
|
70
|
+
return self._tools
|
|
71
|
+
|
|
72
|
+
def has_tool_changes(self, current_tool_names: set[str]) -> bool:
|
|
73
|
+
new_tool_names = {tool.name for tool in self.tools}
|
|
74
|
+
return new_tool_names != current_tool_names
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def main():
|
|
78
|
+
# Initialize the LLM
|
|
79
|
+
llm = ChatOpenAI(model="gpt-4o")
|
|
80
|
+
|
|
81
|
+
# Instantiate the custom server manager
|
|
82
|
+
simple_server_manager = SimpleServerManager()
|
|
83
|
+
|
|
84
|
+
# Create an MCPAgent with the custom server manager
|
|
85
|
+
agent = MCPAgent(
|
|
86
|
+
llm=llm,
|
|
87
|
+
use_server_manager=True,
|
|
88
|
+
server_manager=simple_server_manager,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# Manually initialize the agent
|
|
92
|
+
await agent.initialize()
|
|
93
|
+
|
|
94
|
+
# Run the agent with a query that uses the custom tool
|
|
95
|
+
print("--- First run: calling hello_world ---")
|
|
96
|
+
result = await agent.run("Use the hello_world tool", manage_connector=False)
|
|
97
|
+
print(result)
|
|
98
|
+
|
|
99
|
+
# Clear the conversation history to avoid confusion
|
|
100
|
+
agent.clear_conversation_history()
|
|
101
|
+
|
|
102
|
+
# Run the agent again to show that the new tool is available
|
|
103
|
+
print("\n--- Second run: calling the new dynamic tool ---")
|
|
104
|
+
result = await agent.run("Use the dynamic_tool_1", manage_connector=False)
|
|
105
|
+
print(result)
|
|
106
|
+
|
|
107
|
+
# Manually close the agent
|
|
108
|
+
await agent.close()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
asyncio.run(main())
|
|
@@ -7,12 +7,16 @@ to MCP tools through existing LangChain adapters.
|
|
|
7
7
|
|
|
8
8
|
from importlib.metadata import version
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# Import logging FIRST to ensure it's configured before other modules
|
|
11
|
+
# This MUST happen before importing observability to ensure loggers are configured
|
|
12
|
+
from .logging import MCP_USE_DEBUG, Logger, logger # isort: skip
|
|
13
|
+
|
|
14
|
+
# Now import other modules - observability must come after logging
|
|
15
|
+
from . import observability # noqa: E402
|
|
11
16
|
from .agents.mcpagent import MCPAgent
|
|
12
17
|
from .client import MCPClient
|
|
13
18
|
from .config import load_config_file
|
|
14
19
|
from .connectors import BaseConnector, HttpConnector, StdioConnector, WebSocketConnector
|
|
15
|
-
from .logging import MCP_USE_DEBUG, Logger, logger
|
|
16
20
|
from .session import MCPSession
|
|
17
21
|
|
|
18
22
|
__version__ = version("mcp-use")
|