mcp-use 1.2.13__tar.gz → 1.3.1__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.

Files changed (147) hide show
  1. {mcp_use-1.2.13 → mcp_use-1.3.1}/.github/workflows/publish.yml +56 -6
  2. mcp_use-1.3.1/.github/workflows/transportstests.yml +41 -0
  3. {mcp_use-1.2.13 → mcp_use-1.3.1}/.github/workflows/unittests.yml +1 -1
  4. mcp_use-1.3.1/.github/workflows/update-readme.yml +110 -0
  5. {mcp_use-1.2.13 → mcp_use-1.3.1}/.gitignore +4 -0
  6. mcp_use-1.3.1/CLAUDE.md +204 -0
  7. {mcp_use-1.2.13 → mcp_use-1.3.1}/PKG-INFO +209 -32
  8. {mcp_use-1.2.13 → mcp_use-1.3.1}/README.md +203 -30
  9. mcp_use-1.3.1/docs/api-reference/adapters.mdx +491 -0
  10. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/api-reference/introduction.mdx +141 -15
  11. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/api-reference/mcpagent.mdx +8 -0
  12. mcp_use-1.3.1/docs/api-reference/mcpclient.mdx +451 -0
  13. mcp_use-1.3.1/docs/changelog.mdx +43 -0
  14. mcp_use-1.3.1/docs/development/telemetry.mdx +171 -0
  15. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/development.mdx +2 -1
  16. mcp_use-1.3.1/docs/docs.json +250 -0
  17. mcp_use-1.3.1/docs/essentials/agent-configuration.mdx +473 -0
  18. mcp_use-1.3.1/docs/essentials/client-configuration.mdx +270 -0
  19. mcp_use-1.3.1/docs/essentials/configuration.mdx +162 -0
  20. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/essentials/connection-types.mdx +66 -3
  21. mcp_use-1.3.1/docs/essentials/llm-integration.mdx +306 -0
  22. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/essentials/server-manager.mdx +1 -0
  23. mcp_use-1.3.1/docs/fonts.css +24 -0
  24. {mcp_use-1.2.13/docs → mcp_use-1.3.1/docs/guides}/building-custom-agents.mdx +85 -24
  25. mcp_use-1.3.1/docs/guides/debugging.mdx +175 -0
  26. mcp_use-1.3.1/docs/guides/multi-server-setup.mdx +451 -0
  27. mcp_use-1.3.1/docs/guides/security.mdx +596 -0
  28. mcp_use-1.3.1/docs/guides/streaming.mdx +453 -0
  29. mcp_use-1.3.1/docs/images/01.png +0 -0
  30. mcp_use-1.3.1/docs/images/02.png +0 -0
  31. mcp_use-1.3.1/docs/images/configuration-dark.png +0 -0
  32. mcp_use-1.3.1/docs/images/configuration-light.png +0 -0
  33. mcp_use-1.3.1/docs/images/examples-dark.png +0 -0
  34. mcp_use-1.3.1/docs/images/examples-light.png +0 -0
  35. mcp_use-1.3.1/docs/images/installation-dark.png +0 -0
  36. mcp_use-1.3.1/docs/images/installation-light.png +0 -0
  37. mcp_use-1.3.1/docs/images/quickstart-dark.png +0 -0
  38. mcp_use-1.3.1/docs/images/quickstart-light.png +0 -0
  39. mcp_use-1.3.1/docs/index.mdx +187 -0
  40. mcp_use-1.3.1/docs/installation.mdx +303 -0
  41. mcp_use-1.3.1/docs/logo/light.svg +8 -0
  42. mcp_use-1.3.1/docs/logo/react.svg +1 -0
  43. mcp_use-1.3.1/docs/quickstart.mdx +184 -0
  44. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/snippets/snippet-intro.mdx +6 -0
  45. mcp_use-1.3.1/docs/troubleshooting/common-issues.mdx +386 -0
  46. mcp_use-1.3.1/docs/troubleshooting/connection-errors.mdx +666 -0
  47. mcp_use-1.3.1/docs/troubleshooting/performance.mdx +553 -0
  48. mcp_use-1.3.1/examples/sandbox_everything.py +66 -0
  49. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/agents/mcpagent.py +117 -22
  50. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/client.py +35 -9
  51. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/config.py +30 -4
  52. mcp_use-1.3.1/mcp_use/connectors/__init__.py +20 -0
  53. mcp_use-1.3.1/mcp_use/connectors/base.py +321 -0
  54. mcp_use-1.3.1/mcp_use/connectors/http.py +160 -0
  55. mcp_use-1.3.1/mcp_use/connectors/sandbox.py +296 -0
  56. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/connectors/stdio.py +7 -2
  57. mcp_use-1.3.1/mcp_use/connectors/utils.py +13 -0
  58. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/connectors/websocket.py +7 -2
  59. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/session.py +1 -4
  60. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/task_managers/__init__.py +2 -1
  61. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/task_managers/base.py +10 -4
  62. mcp_use-1.3.1/mcp_use/task_managers/streamable_http.py +81 -0
  63. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/task_managers/websocket.py +5 -0
  64. mcp_use-1.3.1/mcp_use/telemetry/__init__.py +0 -0
  65. mcp_use-1.3.1/mcp_use/telemetry/events.py +93 -0
  66. mcp_use-1.3.1/mcp_use/telemetry/posthog.py +214 -0
  67. mcp_use-1.3.1/mcp_use/telemetry/utils.py +48 -0
  68. mcp_use-1.3.1/mcp_use/types/sandbox.py +23 -0
  69. mcp_use-1.3.1/mcp_use/utils.py +27 -0
  70. {mcp_use-1.2.13 → mcp_use-1.3.1}/pyproject.toml +7 -2
  71. {mcp_use-1.2.13 → mcp_use-1.3.1}/ruff.toml +2 -2
  72. mcp_use-1.3.1/static/logo_white.svg +8 -0
  73. mcp_use-1.3.1/tests/integration/__init__.py +1 -0
  74. mcp_use-1.3.1/tests/integration/servers_for_testing/__init__.py +1 -0
  75. mcp_use-1.3.1/tests/integration/servers_for_testing/custom_streaming_server.py +224 -0
  76. mcp_use-1.3.1/tests/integration/servers_for_testing/long_timeout_test_server.py +144 -0
  77. mcp_use-1.3.1/tests/integration/servers_for_testing/simple_server.py +32 -0
  78. mcp_use-1.3.1/tests/integration/servers_for_testing/timeout_test_server.py +137 -0
  79. mcp_use-1.3.1/tests/integration/transports/customStreaming/__init__.py +1 -0
  80. mcp_use-1.3.1/tests/integration/transports/customStreaming/test_custom_streaming_integration.py +304 -0
  81. mcp_use-1.3.1/tests/integration/transports/sse/test_connection_state_tracking.py +399 -0
  82. mcp_use-1.3.1/tests/integration/transports/sse/test_sse_integration.py +71 -0
  83. mcp_use-1.3.1/tests/integration/transports/stdio/test_stdio_integration.py +53 -0
  84. mcp_use-1.3.1/tests/integration/transports/streamableHttp/test_streamable_http_integration.py +74 -0
  85. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_client.py +6 -2
  86. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_config.py +97 -1
  87. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_http_connector.py +137 -55
  88. mcp_use-1.3.1/tests/unit/test_sandbox_connector.py +308 -0
  89. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_session.py +7 -9
  90. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_stdio_connector.py +38 -25
  91. mcp_use-1.3.1/tests/unit/test_websocket_connection_manager.py +81 -0
  92. mcp_use-1.2.13/docs/docs.json +0 -88
  93. mcp_use-1.2.13/docs/essentials/configuration.mdx +0 -207
  94. mcp_use-1.2.13/docs/essentials/debugging.mdx +0 -103
  95. mcp_use-1.2.13/docs/essentials/llm-integration.mdx +0 -26
  96. mcp_use-1.2.13/docs/introduction.mdx +0 -62
  97. mcp_use-1.2.13/docs/logo/dark.svg +0 -7
  98. mcp_use-1.2.13/docs/logo/light.svg +0 -7
  99. mcp_use-1.2.13/docs/quickstart.mdx +0 -351
  100. mcp_use-1.2.13/mcp_use/connectors/__init__.py +0 -13
  101. mcp_use-1.2.13/mcp_use/connectors/base.py +0 -223
  102. mcp_use-1.2.13/mcp_use/connectors/http.py +0 -82
  103. {mcp_use-1.2.13 → mcp_use-1.3.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  104. {mcp_use-1.2.13 → mcp_use-1.3.1}/.github/pull_request_template.md +0 -0
  105. {mcp_use-1.2.13 → mcp_use-1.3.1}/.pre-commit-config.yaml +0 -0
  106. {mcp_use-1.2.13 → mcp_use-1.3.1}/CONTRIBUTING.md +0 -0
  107. {mcp_use-1.2.13 → mcp_use-1.3.1}/LICENSE +0 -0
  108. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/README.md +0 -0
  109. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/favicon.svg +0 -0
  110. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/images/hero-dark.png +0 -0
  111. {mcp_use-1.2.13 → mcp_use-1.3.1}/docs/images/hero-light.png +0 -0
  112. /mcp_use-1.2.13/static/logo_white.svg → /mcp_use-1.3.1/docs/logo/dark.svg +0 -0
  113. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/airbnb_mcp.json +0 -0
  114. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/airbnb_use.py +0 -0
  115. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/blender_use.py +0 -0
  116. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/browser_mcp.json +0 -0
  117. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/browser_use.py +0 -0
  118. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/chat_example.py +0 -0
  119. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/filesystem_use.py +0 -0
  120. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/http_example.py +0 -0
  121. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/mcp_everything.py +0 -0
  122. {mcp_use-1.2.13 → mcp_use-1.3.1}/examples/multi_server_example.py +0 -0
  123. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/__init__.py +0 -0
  124. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/adapters/__init__.py +0 -0
  125. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/adapters/base.py +0 -0
  126. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/adapters/langchain_adapter.py +0 -0
  127. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/agents/__init__.py +0 -0
  128. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/agents/base.py +0 -0
  129. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/agents/prompts/system_prompt_builder.py +0 -0
  130. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/agents/prompts/templates.py +0 -0
  131. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/logging.py +0 -0
  132. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/__init__.py +0 -0
  133. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/server_manager.py +0 -0
  134. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/__init__.py +0 -0
  135. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/base_tool.py +0 -0
  136. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/connect_server.py +0 -0
  137. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/disconnect_server.py +0 -0
  138. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/get_active_server.py +0 -0
  139. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/list_servers_tool.py +0 -0
  140. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/search_tools.py +0 -0
  141. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/managers/tools/use_tool.py +0 -0
  142. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/task_managers/sse.py +0 -0
  143. {mcp_use-1.2.13 → mcp_use-1.3.1}/mcp_use/task_managers/stdio.py +0 -0
  144. {mcp_use-1.2.13 → mcp_use-1.3.1}/pytest.ini +0 -0
  145. {mcp_use-1.2.13 → mcp_use-1.3.1}/static/logo_black.svg +0 -0
  146. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/conftest.py +0 -0
  147. {mcp_use-1.2.13 → mcp_use-1.3.1}/tests/unit/test_logging.py +0 -0
@@ -1,4 +1,4 @@
1
- name: Check Version Bump and Publish to PyPI
1
+ name: Release
2
2
 
3
3
  on:
4
4
  workflow_run:
@@ -66,14 +66,64 @@ jobs:
66
66
  - name: Create Release
67
67
  if: steps.check-version.outputs.is_new_version == 'true'
68
68
  id: create_release
69
- uses: actions/create-release@v1
70
- env:
71
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69
+ uses: ncipollo/release-action@v1
72
70
  with:
73
- tag_name: v${{ steps.check-version.outputs.new_version }}
74
- release_name: Release v${{ steps.check-version.outputs.new_version }}
71
+ tag: v${{ steps.check-version.outputs.new_version }}
72
+ name: Release v${{ steps.check-version.outputs.new_version }}
75
73
  draft: false
76
74
  prerelease: false
75
+ generateReleaseNotes: true
76
+
77
+ - name: Update Docs Changelog
78
+ if: steps.check-version.outputs.is_new_version == 'true'
79
+ run: |
80
+ # Get the release notes from the created release
81
+ RELEASE_NOTES=$(gh release view v${{ steps.check-version.outputs.new_version }} --json body --jq '.body')
82
+
83
+ # Get current date in the required format
84
+ CURRENT_DATE=$(date +"%Y‑%m‑%d")
85
+
86
+ # Create the new changelog entry
87
+ NEW_ENTRY="<Update label=\"$CURRENT_DATE\">
88
+ ## v${{ steps.check-version.outputs.new_version }}
89
+ $RELEASE_NOTES
90
+ </Update>
91
+
92
+ "
93
+
94
+ # Read the current changelog and insert the new entry after the front matter
95
+ python -c "
96
+ import re
97
+
98
+ # Read the current changelog
99
+ with open('docs/changelog.mdx', 'r') as f:
100
+ content = f.read()
101
+
102
+ # Find the end of the front matter
103
+ front_matter_end = content.find('---', content.find('---') + 1) + 3
104
+
105
+ # Split content into front matter and body
106
+ front_matter = content[:front_matter_end]
107
+ body = content[front_matter_end:]
108
+
109
+ # Create new entry
110
+ new_entry = '''$NEW_ENTRY'''
111
+
112
+ # Combine and write back
113
+ new_content = front_matter + '\n\n' + new_entry + body.lstrip()
114
+
115
+ with open('docs/changelog.mdx', 'w') as f:
116
+ f.write(new_content)
117
+ "
118
+
119
+ # Commit and push the updated changelog
120
+ git config --local user.email "action@github.com"
121
+ git config --local user.name "GitHub Action"
122
+ git add docs/changelog.mdx
123
+ git commit -m "docs: update changelog for v${{ steps.check-version.outputs.new_version }}" || echo "No changes to commit"
124
+ git push || echo "No changes to push"
125
+ env:
126
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
127
 
78
128
  - name: Publish to PyPI
79
129
  if: steps.check-version.outputs.is_new_version == 'true'
@@ -0,0 +1,41 @@
1
+ name: Transports
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ branches: [main]
7
+
8
+ jobs:
9
+ transports:
10
+ name: "${{ matrix.transport }}"
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ transport: [stdio, sse, streamableHttp]
16
+ python-version: ["3.11"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v4
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install uv
27
+ run: |
28
+ pip install uv
29
+
30
+ - name: Install dependencies
31
+ run: |
32
+ # Install project with dev and optional extras similar to unit tests environment
33
+ uv pip install --system .[dev,anthropic,openai,search,e2b]
34
+
35
+ - name: Lint with ruff
36
+ run: |
37
+ ruff check .
38
+
39
+ - name: Run integration tests for ${{ matrix.transport }} transport
40
+ run: |
41
+ pytest tests/integration/transports/${{ matrix.transport }}
@@ -22,7 +22,7 @@ jobs:
22
22
  - name: Install dependencies
23
23
  run: |
24
24
  python -m pip install --upgrade pip
25
- pip install .[dev,anthropic,openai,search]
25
+ pip install .[dev,anthropic,openai,search,e2b]
26
26
  - name: Lint with ruff
27
27
  run: |
28
28
  ruff check .
@@ -0,0 +1,110 @@
1
+ name: Update README
2
+
3
+ on:
4
+ # On manual launch
5
+ workflow_dispatch:
6
+ # Scheduled interval: Use CRON format https://crontab.guru/
7
+ schedule:
8
+ - cron: "0 0 * * 0" # Every sunday at midnight
9
+
10
+ permissions: read-all
11
+
12
+ concurrency:
13
+ group: ${{ github.ref }}-${{ github.workflow }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ update-dependents:
18
+ name: Update GitHub Dependents Info
19
+ runs-on: ubuntu-latest
20
+ permissions:
21
+ contents: write
22
+ pull-requests: write
23
+ steps:
24
+ # Git Checkout
25
+ - name: Checkout Code
26
+ uses: actions/checkout@v4
27
+ with:
28
+ token: ${{ secrets.GITHUB_TOKEN }}
29
+ fetch-depth: 0
30
+
31
+ # Setup Python
32
+ - name: Setup Python
33
+ uses: actions/setup-python@v4
34
+ with:
35
+ python-version: '3.11'
36
+
37
+ # Install github-dependents-info
38
+ - name: Install github-dependents-info
39
+ run: pip install -U github-dependents-info
40
+
41
+ # Generate dependents info
42
+ - name: Generate GitHub Dependents Info
43
+ run: |
44
+ # Get dependents data in JSON format
45
+ github-dependents-info --repo ${{ github.repository }} --sort stars --minstars 1 --json > dependents.json
46
+
47
+ # Extract total count and stars
48
+ TOTAL_REPOS=$(jq -r '.total_dependents_number' dependents.json)
49
+ PUBLIC_REPOS=$(jq -r '.public_dependents_number' dependents.json)
50
+ TOTAL_STARS=$(jq -r '[.all_public_dependent_repos[].stars] | add' dependents.json)
51
+
52
+ # Create the dependents table using HTML for full width
53
+ cat > dependents_table.md << 'EOF'
54
+ <table>
55
+ <tr>
56
+ <th width="400">Repository</th>
57
+ <th>Stars</th>
58
+ </tr>
59
+ EOF
60
+
61
+ # Add top repositories to the table (limit to top 10) with avatars
62
+ jq -r '.all_public_dependent_repos[:10] | .[] | " <tr>\n <td><img src=\"\(.img)\" width=\"20\" height=\"20\" style=\"vertical-align: middle; margin-right: 8px;\"> <a href=\"https://github.com/\(.name)\"><strong>\(.owner)/\(.repo_name)</strong></a></td>\n <td>⭐ \(.stars)</td>\n </tr>"' dependents.json >> dependents_table.md
63
+
64
+ # Close the table
65
+ echo "</table>" >> dependents_table.md
66
+
67
+ # Update README by replacing content between tags
68
+ awk '
69
+ BEGIN { in_section = 0 }
70
+ /<!-- gh-dependents-info-used-by-start -->/ {
71
+ print $0
72
+ print ""
73
+ system("cat dependents_table.md")
74
+ print ""
75
+ in_section = 1
76
+ next
77
+ }
78
+ /<!-- gh-dependents-info-used-by-end -->/ {
79
+ in_section = 0
80
+ print $0
81
+ next
82
+ }
83
+ !in_section { print }
84
+ ' README.md > README_updated.md
85
+
86
+ mv README_updated.md README.md
87
+ rm dependents_table.md dependents.json
88
+ env:
89
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90
+
91
+ # Check for changes and commit directly
92
+ - name: Check for changes
93
+ id: changes
94
+ run: |
95
+ if git diff --quiet README.md; then
96
+ echo "has_changes=false" >> $GITHUB_OUTPUT
97
+ else
98
+ echo "has_changes=true" >> $GITHUB_OUTPUT
99
+ fi
100
+
101
+ - name: Create Pull Request
102
+ if: steps.changes.outputs.has_changes == 'true'
103
+ uses: peter-evans/create-pull-request@v6
104
+ with:
105
+ token: ${{ secrets.GITHUB_TOKEN }}
106
+ commit-message: "chore: update dependents info (automated)"
107
+ title: "chore: update dependents info (automated)"
108
+ body: "This PR updates the README with the latest dependents information."
109
+ branch: chore/update-dependents-info-${{ github.run_id }}
110
+ delete-branch: true
@@ -122,3 +122,7 @@ dmypy.json
122
122
 
123
123
  # macOS
124
124
  .DS_Store
125
+
126
+ # AI
127
+ .cursor
128
+ .claude
@@ -0,0 +1,204 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **mcp-use** is a unified MCP (Model Context Protocol) client library that enables any LLM to connect to MCP servers and build custom agents with tool access. The library provides a high-level Python interface for connecting LangChain-compatible LLMs to MCP tools like web browsing, file operations, and more.
8
+
9
+ ## Development Commands
10
+
11
+ ### Setup
12
+ ```bash
13
+ # Install for development
14
+ pip install -e ".[dev,search]"
15
+
16
+ # Install with optional dependencies
17
+ pip install -e ".[dev,anthropic,openai,e2b,search]"
18
+ ```
19
+
20
+ ### Code Quality
21
+ ```bash
22
+ # Run linting and formatting
23
+ ruff check --fix
24
+ ruff format
25
+
26
+ # Run type checking
27
+ mypy mcp_use/
28
+
29
+ # Run pre-commit hooks
30
+ pre-commit run --all-files
31
+ ```
32
+
33
+ ### Testing
34
+ ```bash
35
+ # Run all tests
36
+ pytest
37
+
38
+ # Run specific test types
39
+ pytest tests/unit/ # Unit tests only
40
+ pytest tests/integration/ # Integration tests only
41
+
42
+ # Run with coverage
43
+ pytest --cov=mcp_use --cov-report=html
44
+
45
+ # Run specific test file
46
+ pytest tests/unit/test_client.py
47
+
48
+ # Run with debug output
49
+ DEBUG=2 pytest tests/unit/test_client.py -v -s
50
+ ```
51
+
52
+ ### Local Development
53
+ ```bash
54
+ # Debug mode environment variable
55
+ export DEBUG=1 # INFO level
56
+ export DEBUG=2 # DEBUG level (full verbose)
57
+
58
+ # Or set MCP_USE_DEBUG
59
+ export MCP_USE_DEBUG=2
60
+ ```
61
+
62
+ ## Architecture Overview
63
+
64
+ ### Core Components
65
+
66
+ **MCPClient** (`mcp_use/client.py`)
67
+ - Main entry point for MCP server management
68
+ - Handles configuration loading from files or dictionaries
69
+ - Manages multiple MCP server sessions
70
+ - Supports sandboxed execution via E2B
71
+
72
+ **MCPAgent** (`mcp_use/agents/mcpagent.py`)
73
+ - High-level agent interface using LangChain's agent framework
74
+ - Integrates LLMs with MCP tools
75
+ - Supports streaming responses and conversation memory
76
+ - Can use ServerManager for dynamic server selection
77
+
78
+ **MCPSession** (`mcp_use/session.py`)
79
+ - Manages individual MCP server connections
80
+ - Handles tool discovery and resource management
81
+ - Maintains connection state and lifecycle
82
+
83
+ **Connectors** (`mcp_use/connectors/`)
84
+ - Abstraction layer for different MCP transport protocols
85
+ - `StdioConnector`: Process-based MCP servers
86
+ - `HttpConnector`: HTTP-based MCP servers
87
+ - `WebSocketConnector`: WebSocket-based MCP servers
88
+ - `SandboxConnector`: E2B sandboxed execution
89
+
90
+ **ServerManager** (`mcp_use/managers/server_manager.py`)
91
+ - Provides dynamic server selection capabilities
92
+ - Allows agents to choose appropriate servers for tasks
93
+ - Manages server tool discovery and activation
94
+
95
+ ### Key Patterns
96
+
97
+ **Configuration-Driven Design**: Servers are configured via JSON files or dictionaries with `mcpServers` key containing server definitions.
98
+
99
+ **Async/Await**: All I/O operations are asynchronous using asyncio patterns.
100
+
101
+ **LangChain Integration**: Tools are converted to LangChain format via adapters, enabling use with any LangChain-compatible LLM.
102
+
103
+ **Multi-Transport Support**: Supports stdio, HTTP, WebSocket, and sandboxed connections to MCP servers.
104
+
105
+ **Telemetry**: Built-in telemetry using PostHog for usage analytics (can be disabled).
106
+
107
+ ## Configuration Examples
108
+
109
+ ### Basic Server Configuration
110
+ ```json
111
+ {
112
+ "mcpServers": {
113
+ "playwright": {
114
+ "command": "npx",
115
+ "args": ["@playwright/mcp@latest"],
116
+ "env": {"DISPLAY": ":1"}
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### HTTP Server Configuration
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "http_server": {
127
+ "url": "http://localhost:8931/sse"
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ ### Multi-Server Configuration
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "playwright": {
138
+ "command": "npx",
139
+ "args": ["@playwright/mcp@latest"]
140
+ },
141
+ "airbnb": {
142
+ "command": "npx",
143
+ "args": ["-y", "@openbnb/mcp-server-airbnb"]
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ ## Code Style and Standards
150
+
151
+ - **Line Length**: 200 characters (configured in ruff.toml)
152
+ - **Python Version**: 3.11+ required
153
+ - **Formatting**: Use Ruff for formatting and linting
154
+ - **Type Hints**: All public APIs should have type hints
155
+ - **Async Patterns**: Use async/await consistently for I/O operations
156
+ - **Error Handling**: Proper exception handling with logging
157
+ - **Documentation**: Docstrings follow Google style
158
+
159
+ ## Testing Strategy
160
+
161
+ ### Unit Tests (`tests/unit/`)
162
+ - Test individual components in isolation
163
+ - Mock external dependencies
164
+ - Focus on business logic and edge cases
165
+
166
+ ### Integration Tests (`tests/integration/`)
167
+ - Test component interactions
168
+ - Include real MCP server integrations
169
+ - Organized by transport type (stdio, sse, websocket, etc.)
170
+ - Custom test servers in `tests/integration/servers_for_testing/`
171
+
172
+ ### Test Configuration
173
+ - Uses pytest with asyncio mode
174
+ - Fixtures defined in `conftest.py`
175
+ - Test servers provide controlled MCP environments
176
+
177
+ ## Important Development Notes
178
+
179
+ - **Environment Setup**: Requires Python 3.11+ and appropriate LangChain provider packages
180
+ - **MCP Protocol**: Built on Model Context Protocol specification
181
+ - **LangChain Compatibility**: Only models with tool calling capabilities are supported
182
+ - **Resource Management**: Always properly close sessions to avoid resource leaks
183
+ - **Debugging**: Use DEBUG environment variable or `mcp_use.set_debug()` for verbose logging
184
+ - **Memory Management**: MCPAgent supports conversation memory for context retention
185
+ - **Security**: Tool access can be restricted via `disallowed_tools` parameter
186
+
187
+ ## Common Development Tasks
188
+
189
+ ### Adding a New Connector
190
+ 1. Extend `BaseConnector` in `mcp_use/connectors/`
191
+ 2. Implement required async methods
192
+ 3. Add connector to factory in `config.py`
193
+ 4. Write integration tests
194
+
195
+ ### Adding New Agent Features
196
+ 1. Modify `MCPAgent` class in `mcp_use/agents/mcpagent.py`
197
+ 2. Update system prompt templates if needed
198
+ 3. Add comprehensive tests
199
+ 4. Update documentation
200
+
201
+ ### Testing with Custom MCP Servers
202
+ 1. Create test server in `tests/integration/servers_for_testing/`
203
+ 2. Add integration test in appropriate transport directory
204
+ 3. Use custom servers for controlled testing scenarios