mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 22:17:00 +00:00
Sign in to MCP presets from the connect wizard
Notion, Linear, Atlassian, Sentry, Asana and Stripe no longer open the MCP server form. The wizard shows one "Sign in to Notion" button: the pop-up opens inside the click (so browsers allow it), follows the worker's mcp.oauth events to the provider, and the tool is saved on success with its actions on the done step. Reconnecting a preset uses the same flow, as do the chat bar and the health toast. Saving an OAuth MCP server without a new handshake now uses the stored sign-in instead of failing, and the custom MCP form keeps scopes and timeout under Show advanced.
This commit is contained in:
1 parent
f6c89503d8
commit
bfcc4a9773
18 files changed
+470
-57
No files matched your search
@@ -328,7 +328,10 @@ class TestMCPServerSave:
|
||||
def test_oauth_missing_task_id_returns_400(self, app):
|
||||
from docsgpt.api.user.tools.mcp import MCPServerSave
|
||||
|
||||
with app.test_request_context(
|
||||
# No OAuth task and no stored sign-in that works.
|
||||
unauthorized = MagicMock()
|
||||
unauthorized.discover_tools.side_effect = RuntimeError("401")
|
||||
with patch("docsgpt.api.user.tools.mcp.MCPTool", return_value=unauthorized), app.test_request_context(
|
||||
"/api/mcp_server/save", method="POST",
|
||||
json={
|
||||
"displayName": "Srv",
|
||||
@@ -344,6 +347,31 @@ class TestMCPServerSave:
|
||||
response = MCPServerSave().post()
|
||||
assert response.status_code == 400
|
||||
|
||||
def test_oauth_without_task_uses_the_stored_sign_in(self, app, pg_conn):
|
||||
"""Signed in before: the server answers with the saved tokens, no new handshake."""
|
||||
from docsgpt.api.user.tools.mcp import MCPServerSave
|
||||
|
||||
signed_in = MagicMock()
|
||||
signed_in.get_actions_metadata.return_value = [{"name": "search"}]
|
||||
with _patch_db(pg_conn), patch(
|
||||
"docsgpt.api.user.tools.mcp.MCPTool", return_value=signed_in,
|
||||
), patch("docsgpt.api.user.tools.mcp._mcp_connection", return_value=None), app.test_request_context(
|
||||
"/api/mcp_server/save", method="POST",
|
||||
json={
|
||||
"displayName": "Linear",
|
||||
"config": {
|
||||
"transport_type": "http",
|
||||
"server_url": "https://mcp.linear.app/mcp",
|
||||
"auth_type": "oauth",
|
||||
},
|
||||
},
|
||||
):
|
||||
from flask import request
|
||||
request.decoded_token = {"sub": "u-signed-in"}
|
||||
response = MCPServerSave().post()
|
||||
assert response.status_code == 200
|
||||
signed_in.discover_tools.assert_called_once()
|
||||
|
||||
def test_creates_mcp_tool_successfully(self, app, pg_conn):
|
||||
from docsgpt.api.user.tools.mcp import MCPServerSave
|
||||
|
||||
|
||||
Reference in new issue
Block a user