|
9 | 9 | from ..types.create_server_response import CreateServerResponse |
10 | 10 | from ..types.get_instance_response import GetInstanceResponse |
11 | 11 | from ..types.get_mcp_servers_response import GetMcpServersResponse |
| 12 | +from ..types.get_o_auth_url_response import GetOAuthUrlResponse |
12 | 13 | from ..types.get_tools_response import GetToolsResponse |
13 | 14 | from ..types.list_tools_response import ListToolsResponse |
14 | 15 | from ..types.mcp_server_name import McpServerName |
@@ -400,6 +401,67 @@ def set_instance_auth_token( |
400 | 401 | ) |
401 | 402 | return _response.data |
402 | 403 |
|
| 404 | + def get_o_auth_url( |
| 405 | + self, |
| 406 | + *, |
| 407 | + server_name: McpServerName, |
| 408 | + instance_id: str, |
| 409 | + client_id: typing.Optional[str] = OMIT, |
| 410 | + scope: typing.Optional[str] = OMIT, |
| 411 | + redirect_url: typing.Optional[str] = OMIT, |
| 412 | + request_options: typing.Optional[RequestOptions] = None, |
| 413 | + ) -> GetOAuthUrlResponse: |
| 414 | + """ |
| 415 | + Gets the OAuth authorization URL for a specific MCP server and instance. |
| 416 | + Returns the complete OAuth URL with the instance ID as a query parameter. |
| 417 | +
|
| 418 | + Parameters |
| 419 | + ---------- |
| 420 | + server_name : McpServerName |
| 421 | + The name of the target MCP server. |
| 422 | +
|
| 423 | + instance_id : str |
| 424 | + The unique identifier for the connection instance. |
| 425 | +
|
| 426 | + client_id : typing.Optional[str] |
| 427 | + Optional client ID for white labeling. If not provided, will use default credentials. |
| 428 | +
|
| 429 | + scope : typing.Optional[str] |
| 430 | + Optional OAuth scopes to request (comma-separated string). |
| 431 | +
|
| 432 | + redirect_url : typing.Optional[str] |
| 433 | + Optional URL to redirect to after authorization completes. |
| 434 | +
|
| 435 | + request_options : typing.Optional[RequestOptions] |
| 436 | + Request-specific configuration. |
| 437 | +
|
| 438 | + Returns |
| 439 | + ------- |
| 440 | + GetOAuthUrlResponse |
| 441 | + Successful Response |
| 442 | +
|
| 443 | + Examples |
| 444 | + -------- |
| 445 | + from klavis import Klavis, McpServerName |
| 446 | +
|
| 447 | + client = Klavis( |
| 448 | + token="YOUR_TOKEN", |
| 449 | + ) |
| 450 | + client.mcp_server.get_o_auth_url( |
| 451 | + server_name=McpServerName.MARKDOWN2DOC, |
| 452 | + instance_id="instanceId", |
| 453 | + ) |
| 454 | + """ |
| 455 | + _response = self._raw_client.get_o_auth_url( |
| 456 | + server_name=server_name, |
| 457 | + instance_id=instance_id, |
| 458 | + client_id=client_id, |
| 459 | + scope=scope, |
| 460 | + redirect_url=redirect_url, |
| 461 | + request_options=request_options, |
| 462 | + ) |
| 463 | + return _response.data |
| 464 | + |
403 | 465 |
|
404 | 466 | class AsyncMcpServerClient: |
405 | 467 | def __init__(self, *, client_wrapper: AsyncClientWrapper): |
@@ -854,3 +916,72 @@ async def main() -> None: |
854 | 916 | instance_id=instance_id, auth_token=auth_token, request_options=request_options |
855 | 917 | ) |
856 | 918 | return _response.data |
| 919 | + |
| 920 | + async def get_o_auth_url( |
| 921 | + self, |
| 922 | + *, |
| 923 | + server_name: McpServerName, |
| 924 | + instance_id: str, |
| 925 | + client_id: typing.Optional[str] = OMIT, |
| 926 | + scope: typing.Optional[str] = OMIT, |
| 927 | + redirect_url: typing.Optional[str] = OMIT, |
| 928 | + request_options: typing.Optional[RequestOptions] = None, |
| 929 | + ) -> GetOAuthUrlResponse: |
| 930 | + """ |
| 931 | + Gets the OAuth authorization URL for a specific MCP server and instance. |
| 932 | + Returns the complete OAuth URL with the instance ID as a query parameter. |
| 933 | +
|
| 934 | + Parameters |
| 935 | + ---------- |
| 936 | + server_name : McpServerName |
| 937 | + The name of the target MCP server. |
| 938 | +
|
| 939 | + instance_id : str |
| 940 | + The unique identifier for the connection instance. |
| 941 | +
|
| 942 | + client_id : typing.Optional[str] |
| 943 | + Optional client ID for white labeling. If not provided, will use default credentials. |
| 944 | +
|
| 945 | + scope : typing.Optional[str] |
| 946 | + Optional OAuth scopes to request (comma-separated string). |
| 947 | +
|
| 948 | + redirect_url : typing.Optional[str] |
| 949 | + Optional URL to redirect to after authorization completes. |
| 950 | +
|
| 951 | + request_options : typing.Optional[RequestOptions] |
| 952 | + Request-specific configuration. |
| 953 | +
|
| 954 | + Returns |
| 955 | + ------- |
| 956 | + GetOAuthUrlResponse |
| 957 | + Successful Response |
| 958 | +
|
| 959 | + Examples |
| 960 | + -------- |
| 961 | + import asyncio |
| 962 | +
|
| 963 | + from klavis import AsyncKlavis, McpServerName |
| 964 | +
|
| 965 | + client = AsyncKlavis( |
| 966 | + token="YOUR_TOKEN", |
| 967 | + ) |
| 968 | +
|
| 969 | +
|
| 970 | + async def main() -> None: |
| 971 | + await client.mcp_server.get_o_auth_url( |
| 972 | + server_name=McpServerName.MARKDOWN2DOC, |
| 973 | + instance_id="instanceId", |
| 974 | + ) |
| 975 | +
|
| 976 | +
|
| 977 | + asyncio.run(main()) |
| 978 | + """ |
| 979 | + _response = await self._raw_client.get_o_auth_url( |
| 980 | + server_name=server_name, |
| 981 | + instance_id=instance_id, |
| 982 | + client_id=client_id, |
| 983 | + scope=scope, |
| 984 | + redirect_url=redirect_url, |
| 985 | + request_options=request_options, |
| 986 | + ) |
| 987 | + return _response.data |
0 commit comments