datarobot-genai 0.2.9__tar.gz → 0.2.13__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.
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/PKG-INFO +3 -1
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/pyproject.toml +3 -1
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/openai_llm_mcp_client.py +6 -1
- datarobot_genai-0.2.13/src/datarobot_genai/drmcp/tools/clients/confluence.py +196 -0
- datarobot_genai-0.2.13/src/datarobot_genai/drmcp/tools/clients/jira.py +220 -0
- datarobot_genai-0.2.13/src/datarobot_genai/drmcp/tools/confluence/tools.py +81 -0
- datarobot_genai-0.2.13/src/datarobot_genai/drmcp/tools/jira/tools.py +101 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/datarobot_llm_clients.py +45 -12
- datarobot_genai-0.2.9/src/datarobot_genai/drmcp/tools/clients/confluence.py +0 -14
- datarobot_genai-0.2.9/src/datarobot_genai/drmcp/tools/clients/jira.py +0 -102
- datarobot_genai-0.2.9/src/datarobot_genai/drmcp/tools/confluence/tools.py +0 -13
- datarobot_genai-0.2.9/src/datarobot_genai/drmcp/tools/jira/tools.py +0 -58
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/.gitignore +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/AUTHORS +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/LICENSE +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/README.md +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/agents/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/agents/base.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/chat/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/chat/auth.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/chat/client.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/chat/responses.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/cli/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/cli/agent_environment.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/cli/agent_kernel.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/custom_model.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/mcp/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/mcp/common.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/telemetry_agent.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/utils/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/utils/auth.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/core/utils/urls.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/crewai/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/crewai/agent.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/crewai/base.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/crewai/events.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/crewai/mcp.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/auth.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/clients.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/config.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/config_utils.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/constants.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/credentials.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dr_mcp_server.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dr_mcp_server_logo.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_prompts/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_prompts/controllers.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_prompts/dr_lib.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_prompts/register.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_prompts/utils.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/base.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/default.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/adapters/drum.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/config.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/controllers.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/metadata.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/register.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_agentic_fallback_schema.json +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/deployment/schemas/drum_prediction_fallback_schema.json +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/register.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/dynamic_tools/schema.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/exceptions.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/logging.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/mcp_instance.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/mcp_server_tools.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/memory_management/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/memory_management/manager.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/memory_management/memory_tools.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/routes.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/routes_utils.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/server_life_cycle.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/telemetry.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/tool_config.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/tool_filter.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/core/utils.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/server.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/integration_mcp_server.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/mcp_utils_ete.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/mcp_utils_integration.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/tool_base_ete.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/test_utils/utils.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/clients/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/clients/atlassian.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/clients/s3.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/confluence/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/jira/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/data.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/deployment.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/deployment_info.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/model.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/predict.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/predict_realtime.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/project.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/drmcp/tools/predictive/training.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/langgraph/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/langgraph/agent.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/langgraph/mcp.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/llama_index/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/llama_index/agent.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/llama_index/base.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/llama_index/mcp.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/__init__.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/agent.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/datarobot_auth_provider.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/datarobot_llm_providers.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/nat/datarobot_mcp_client.py +0 -0
- {datarobot_genai-0.2.9 → datarobot_genai-0.2.13}/src/datarobot_genai/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datarobot-genai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.13
|
|
4
4
|
Summary: Generic helpers for GenAI
|
|
5
5
|
Project-URL: Homepage, https://github.com/datarobot-oss/datarobot-genai
|
|
6
6
|
Author: DataRobot, Inc.
|
|
@@ -25,6 +25,8 @@ Requires-Dist: pypdf<7.0.0,>=6.1.3
|
|
|
25
25
|
Requires-Dist: ragas<0.4.0,>=0.3.8
|
|
26
26
|
Requires-Dist: requests<3.0.0,>=2.32.4
|
|
27
27
|
Provides-Extra: crewai
|
|
28
|
+
Requires-Dist: anthropic<1.0.0,~=0.71.0; extra == 'crewai'
|
|
29
|
+
Requires-Dist: azure-ai-inference<2.0.0,>=1.0.0b9; extra == 'crewai'
|
|
28
30
|
Requires-Dist: crewai-tools[mcp]<0.77.0,>=0.69.0; extra == 'crewai'
|
|
29
31
|
Requires-Dist: crewai>=1.1.0; extra == 'crewai'
|
|
30
32
|
Requires-Dist: opentelemetry-instrumentation-crewai<1.0.0,>=0.40.5; extra == 'crewai'
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datarobot-genai"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.13"
|
|
8
8
|
description = "Generic helpers for GenAI"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10, <3.13"
|
|
@@ -40,6 +40,8 @@ datarobot_auth_provider = "datarobot_genai.nat.datarobot_auth_provider"
|
|
|
40
40
|
|
|
41
41
|
[project.optional-dependencies]
|
|
42
42
|
crewai = [
|
|
43
|
+
"anthropic~=0.71.0,<1.0.0", # Needed for integration with anthropic endpoints
|
|
44
|
+
"azure-ai-inference>=1.0.0b9,<2.0.0", # Needed for integration with azure endpoints
|
|
43
45
|
"crewai>=1.1.0",
|
|
44
46
|
"crewai-tools[mcp]>=0.69.0,<0.77.0",
|
|
45
47
|
"opentelemetry-instrumentation-crewai>=0.40.5,<1.0.0",
|
|
@@ -95,11 +95,16 @@ class LLMMCPClient:
|
|
|
95
95
|
) -> str:
|
|
96
96
|
"""Call an MCP tool and return the result as a string."""
|
|
97
97
|
result: CallToolResult = await mcp_session.call_tool(tool_name, parameters)
|
|
98
|
-
|
|
98
|
+
content = (
|
|
99
99
|
result.content[0].text
|
|
100
100
|
if result.content and isinstance(result.content[0], TextContent)
|
|
101
101
|
else str(result.content)
|
|
102
102
|
)
|
|
103
|
+
if result.structuredContent is not None:
|
|
104
|
+
structured_content = json.dumps(result.structuredContent)
|
|
105
|
+
else:
|
|
106
|
+
structured_content = ""
|
|
107
|
+
return f"Content: {content}\nStructured content: {structured_content}"
|
|
103
108
|
|
|
104
109
|
async def _process_tool_calls(
|
|
105
110
|
self,
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Async client for interacting with Confluence Cloud REST API.
|
|
16
|
+
|
|
17
|
+
At the moment of creating this client, official Confluence SDK is not supporting async.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import logging
|
|
21
|
+
from http import HTTPStatus
|
|
22
|
+
from typing import Any
|
|
23
|
+
|
|
24
|
+
import httpx
|
|
25
|
+
from pydantic import BaseModel
|
|
26
|
+
from pydantic import Field
|
|
27
|
+
|
|
28
|
+
from .atlassian import ATLASSIAN_API_BASE
|
|
29
|
+
from .atlassian import get_atlassian_cloud_id
|
|
30
|
+
|
|
31
|
+
logger = logging.getLogger(__name__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class ConfluencePage(BaseModel):
|
|
35
|
+
"""Pydantic model for Confluence page."""
|
|
36
|
+
|
|
37
|
+
page_id: str = Field(..., description="The unique page ID")
|
|
38
|
+
title: str = Field(..., description="Page title")
|
|
39
|
+
space_id: str = Field(..., description="Space ID where the page resides")
|
|
40
|
+
space_key: str | None = Field(None, description="Space key (if available)")
|
|
41
|
+
body: str = Field(..., description="Page content in storage format (HTML-like)")
|
|
42
|
+
|
|
43
|
+
def as_flat_dict(self) -> dict[str, Any]:
|
|
44
|
+
"""Return a flat dictionary representation of the page."""
|
|
45
|
+
return {
|
|
46
|
+
"page_id": self.page_id,
|
|
47
|
+
"title": self.title,
|
|
48
|
+
"space_id": self.space_id,
|
|
49
|
+
"space_key": self.space_key,
|
|
50
|
+
"body": self.body,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ConfluenceClient:
|
|
55
|
+
"""
|
|
56
|
+
Client for interacting with Confluence API using OAuth access token.
|
|
57
|
+
|
|
58
|
+
At the moment of creating this client, official Confluence SDK is not supporting async.
|
|
59
|
+
"""
|
|
60
|
+
|
|
61
|
+
EXPAND_FIELDS = "body.storage,space"
|
|
62
|
+
|
|
63
|
+
def __init__(self, access_token: str) -> None:
|
|
64
|
+
"""
|
|
65
|
+
Initialize Confluence client with access token.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
access_token: OAuth access token for Atlassian API
|
|
69
|
+
"""
|
|
70
|
+
self.access_token = access_token
|
|
71
|
+
self._client = httpx.AsyncClient(
|
|
72
|
+
headers={
|
|
73
|
+
"Authorization": f"Bearer {access_token}",
|
|
74
|
+
"Accept": "application/json",
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
},
|
|
77
|
+
timeout=30.0,
|
|
78
|
+
)
|
|
79
|
+
self._cloud_id: str | None = None
|
|
80
|
+
|
|
81
|
+
async def _get_cloud_id(self) -> str:
|
|
82
|
+
"""
|
|
83
|
+
Get the cloud ID for the authenticated Atlassian Confluence instance.
|
|
84
|
+
|
|
85
|
+
According to Atlassian OAuth 2.0 documentation, API calls should use:
|
|
86
|
+
https://api.atlassian.com/ex/confluence/{cloudId}/wiki/rest/api/...
|
|
87
|
+
|
|
88
|
+
Returns
|
|
89
|
+
-------
|
|
90
|
+
Cloud ID string
|
|
91
|
+
|
|
92
|
+
Raises
|
|
93
|
+
------
|
|
94
|
+
ValueError: If cloud ID cannot be retrieved
|
|
95
|
+
"""
|
|
96
|
+
if self._cloud_id:
|
|
97
|
+
return self._cloud_id
|
|
98
|
+
|
|
99
|
+
self._cloud_id = await get_atlassian_cloud_id(self._client, service_type="confluence")
|
|
100
|
+
return self._cloud_id
|
|
101
|
+
|
|
102
|
+
def _parse_response(self, data: dict) -> ConfluencePage:
|
|
103
|
+
"""Parse API response into ConfluencePage."""
|
|
104
|
+
body_content = ""
|
|
105
|
+
body = data.get("body", {})
|
|
106
|
+
if isinstance(body, dict):
|
|
107
|
+
storage = body.get("storage", {})
|
|
108
|
+
if isinstance(storage, dict):
|
|
109
|
+
body_content = storage.get("value", "")
|
|
110
|
+
|
|
111
|
+
space = data.get("space", {})
|
|
112
|
+
space_key = space.get("key") if isinstance(space, dict) else None
|
|
113
|
+
space_id = space.get("id", "") if isinstance(space, dict) else data.get("spaceId", "")
|
|
114
|
+
|
|
115
|
+
return ConfluencePage(
|
|
116
|
+
page_id=str(data.get("id", "")),
|
|
117
|
+
title=data.get("title", ""),
|
|
118
|
+
space_id=str(space_id),
|
|
119
|
+
space_key=space_key,
|
|
120
|
+
body=body_content,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
async def get_page_by_id(self, page_id: str) -> ConfluencePage:
|
|
124
|
+
"""
|
|
125
|
+
Get a Confluence page by its ID.
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
page_id: The numeric page ID
|
|
129
|
+
|
|
130
|
+
Returns
|
|
131
|
+
-------
|
|
132
|
+
ConfluencePage with page data
|
|
133
|
+
|
|
134
|
+
Raises
|
|
135
|
+
------
|
|
136
|
+
ValueError: If page is not found
|
|
137
|
+
httpx.HTTPStatusError: If the API request fails
|
|
138
|
+
"""
|
|
139
|
+
cloud_id = await self._get_cloud_id()
|
|
140
|
+
url = f"{ATLASSIAN_API_BASE}/ex/confluence/{cloud_id}/wiki/rest/api/content/{page_id}"
|
|
141
|
+
|
|
142
|
+
response = await self._client.get(url, params={"expand": self.EXPAND_FIELDS})
|
|
143
|
+
|
|
144
|
+
if response.status_code == HTTPStatus.NOT_FOUND:
|
|
145
|
+
raise ValueError(f"Page with ID '{page_id}' not found")
|
|
146
|
+
|
|
147
|
+
response.raise_for_status()
|
|
148
|
+
return self._parse_response(response.json())
|
|
149
|
+
|
|
150
|
+
async def get_page_by_title(self, title: str, space_key: str) -> ConfluencePage:
|
|
151
|
+
"""
|
|
152
|
+
Get a Confluence page by its title within a specific space.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
title: The exact page title
|
|
156
|
+
space_key: The space key where the page resides
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
ConfluencePage with page data
|
|
161
|
+
|
|
162
|
+
Raises
|
|
163
|
+
------
|
|
164
|
+
ValueError: If the page is not found
|
|
165
|
+
httpx.HTTPStatusError: If the API request fails
|
|
166
|
+
"""
|
|
167
|
+
cloud_id = await self._get_cloud_id()
|
|
168
|
+
url = f"{ATLASSIAN_API_BASE}/ex/confluence/{cloud_id}/wiki/rest/api/content"
|
|
169
|
+
|
|
170
|
+
response = await self._client.get(
|
|
171
|
+
url,
|
|
172
|
+
params={
|
|
173
|
+
"title": title,
|
|
174
|
+
"spaceKey": space_key,
|
|
175
|
+
"expand": self.EXPAND_FIELDS,
|
|
176
|
+
},
|
|
177
|
+
)
|
|
178
|
+
response.raise_for_status()
|
|
179
|
+
|
|
180
|
+
data = response.json()
|
|
181
|
+
results = data.get("results", [])
|
|
182
|
+
|
|
183
|
+
if not results:
|
|
184
|
+
raise ValueError(f"Page with title '{title}' not found in space '{space_key}'")
|
|
185
|
+
|
|
186
|
+
return self._parse_response(results[0])
|
|
187
|
+
|
|
188
|
+
async def __aenter__(self) -> "ConfluenceClient":
|
|
189
|
+
"""Async context manager entry."""
|
|
190
|
+
return self
|
|
191
|
+
|
|
192
|
+
async def __aexit__(
|
|
193
|
+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any
|
|
194
|
+
) -> None:
|
|
195
|
+
"""Async context manager exit."""
|
|
196
|
+
await self._client.aclose()
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import logging
|
|
16
|
+
from http import HTTPStatus
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
import httpx
|
|
20
|
+
from pydantic import BaseModel
|
|
21
|
+
from pydantic import Field
|
|
22
|
+
|
|
23
|
+
from .atlassian import ATLASSIAN_API_BASE
|
|
24
|
+
from .atlassian import get_atlassian_cloud_id
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class _IssuePerson(BaseModel):
|
|
30
|
+
email_address: str = Field(alias="emailAddress")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class _IssueStatus(BaseModel):
|
|
34
|
+
name: str
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class _IssueFields(BaseModel):
|
|
38
|
+
summary: str
|
|
39
|
+
status: _IssueStatus
|
|
40
|
+
reporter: _IssuePerson
|
|
41
|
+
assignee: _IssuePerson
|
|
42
|
+
created: str
|
|
43
|
+
updated: str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class Issue(BaseModel):
|
|
47
|
+
id: str
|
|
48
|
+
key: str
|
|
49
|
+
fields: _IssueFields
|
|
50
|
+
|
|
51
|
+
def as_flat_dict(self) -> dict[str, Any]:
|
|
52
|
+
return {
|
|
53
|
+
"id": self.id,
|
|
54
|
+
"key": self.key,
|
|
55
|
+
"summary": self.fields.summary,
|
|
56
|
+
"reporterEmailAddress": self.fields.reporter.email_address,
|
|
57
|
+
"assigneeEmailAddress": self.fields.assignee.email_address,
|
|
58
|
+
"created": self.fields.created,
|
|
59
|
+
"updated": self.fields.updated,
|
|
60
|
+
"status": self.fields.status.name,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class JiraClient:
|
|
65
|
+
"""
|
|
66
|
+
Client for interacting with Jira API using OAuth access token.
|
|
67
|
+
|
|
68
|
+
At the moment of creating this client, official Jira SDK is not supporting async.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
def __init__(self, access_token: str) -> None:
|
|
72
|
+
"""
|
|
73
|
+
Initialize Jira client with access token.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
access_token: OAuth access token for Atlassian API
|
|
77
|
+
"""
|
|
78
|
+
self.access_token = access_token
|
|
79
|
+
self._client = httpx.AsyncClient(
|
|
80
|
+
headers={
|
|
81
|
+
"Authorization": f"Bearer {access_token}",
|
|
82
|
+
"Accept": "application/json",
|
|
83
|
+
"Content-Type": "application/json",
|
|
84
|
+
},
|
|
85
|
+
timeout=30.0,
|
|
86
|
+
)
|
|
87
|
+
self._cloud_id: str | None = None
|
|
88
|
+
|
|
89
|
+
async def _get_cloud_id(self) -> str:
|
|
90
|
+
"""
|
|
91
|
+
Get the cloud ID for the authenticated Atlassian Jira instance.
|
|
92
|
+
|
|
93
|
+
According to Atlassian OAuth 2.0 documentation, API calls should use:
|
|
94
|
+
https://api.atlassian.com/ex/jira/{cloudId}/rest/api/3/...
|
|
95
|
+
|
|
96
|
+
Returns
|
|
97
|
+
-------
|
|
98
|
+
Cloud ID string
|
|
99
|
+
|
|
100
|
+
Raises
|
|
101
|
+
------
|
|
102
|
+
ValueError: If cloud ID cannot be retrieved
|
|
103
|
+
"""
|
|
104
|
+
if self._cloud_id:
|
|
105
|
+
return self._cloud_id
|
|
106
|
+
|
|
107
|
+
self._cloud_id = await get_atlassian_cloud_id(self._client, service_type="jira")
|
|
108
|
+
return self._cloud_id
|
|
109
|
+
|
|
110
|
+
async def _get_full_url(self, url: str) -> str:
|
|
111
|
+
"""Return URL for Jira API."""
|
|
112
|
+
cloud_id = await self._get_cloud_id()
|
|
113
|
+
return f"{ATLASSIAN_API_BASE}/ex/jira/{cloud_id}/rest/api/3/{url}"
|
|
114
|
+
|
|
115
|
+
async def get_jira_issue(self, issue_key: str) -> Issue:
|
|
116
|
+
"""
|
|
117
|
+
Get a Jira issue by its key.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
issue_key: The key of the Jira issue, e.g., 'PROJ-123'
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
Jira issue
|
|
125
|
+
|
|
126
|
+
Raises
|
|
127
|
+
------
|
|
128
|
+
httpx.HTTPStatusError: If the API request fails
|
|
129
|
+
"""
|
|
130
|
+
url = await self._get_full_url(f"issue/{issue_key}")
|
|
131
|
+
response = await self._client.get(
|
|
132
|
+
url, params={"fields": "id,key,summary,status,reporter,assignee,created,updated"}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if response.status_code == HTTPStatus.NOT_FOUND:
|
|
136
|
+
raise ValueError(f"{issue_key} not found")
|
|
137
|
+
|
|
138
|
+
response.raise_for_status()
|
|
139
|
+
issue = Issue(**response.json())
|
|
140
|
+
return issue
|
|
141
|
+
|
|
142
|
+
async def get_jira_issue_types(self, project_key: str) -> dict[str, str]:
|
|
143
|
+
"""
|
|
144
|
+
Get Jira issue types possible for given project.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
project_key: The key of the Jira project, e.g., 'PROJ'
|
|
148
|
+
|
|
149
|
+
Returns
|
|
150
|
+
-------
|
|
151
|
+
Dictionary where key is the issue type name and value is the issue type ID
|
|
152
|
+
|
|
153
|
+
Raises
|
|
154
|
+
------
|
|
155
|
+
httpx.HTTPStatusError: If the API request fails
|
|
156
|
+
"""
|
|
157
|
+
url = await self._get_full_url(f"issue/createmeta/{project_key}/issuetypes")
|
|
158
|
+
response = await self._client.get(url)
|
|
159
|
+
|
|
160
|
+
response.raise_for_status()
|
|
161
|
+
jsoned = response.json()
|
|
162
|
+
issue_types = {
|
|
163
|
+
issue_type["untranslatedName"]: issue_type["id"]
|
|
164
|
+
for issue_type in jsoned.get("issueTypes", [])
|
|
165
|
+
}
|
|
166
|
+
return issue_types
|
|
167
|
+
|
|
168
|
+
async def create_jira_issue(
|
|
169
|
+
self, project_key: str, summary: str, issue_type_id: str, description: str | None
|
|
170
|
+
) -> str:
|
|
171
|
+
"""
|
|
172
|
+
Create Jira issue.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
project_key: The key of the Jira project, e.g., 'PROJ'
|
|
176
|
+
summary: Summary of Jira issue (title), e.g., 'Fix bug abc'
|
|
177
|
+
issue_type_id: ID type of Jira issue, e.g., "1"
|
|
178
|
+
description: Optional description of Jira issue
|
|
179
|
+
|
|
180
|
+
Returns
|
|
181
|
+
-------
|
|
182
|
+
Jira issue key
|
|
183
|
+
|
|
184
|
+
Raises
|
|
185
|
+
------
|
|
186
|
+
httpx.HTTPStatusError: If the API request fails
|
|
187
|
+
"""
|
|
188
|
+
url = await self._get_full_url("issue")
|
|
189
|
+
payload = {
|
|
190
|
+
"fields": {
|
|
191
|
+
"project": {"key": project_key},
|
|
192
|
+
"summary": summary,
|
|
193
|
+
"issuetype": {"id": issue_type_id},
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if description:
|
|
198
|
+
payload["fields"]["description"] = {
|
|
199
|
+
"content": [
|
|
200
|
+
{"content": [{"text": description, "type": "text"}], "type": "paragraph"}
|
|
201
|
+
],
|
|
202
|
+
"type": "doc",
|
|
203
|
+
"version": 1,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
response = await self._client.post(url, json=payload)
|
|
207
|
+
|
|
208
|
+
response.raise_for_status()
|
|
209
|
+
jsoned = response.json()
|
|
210
|
+
return jsoned["key"]
|
|
211
|
+
|
|
212
|
+
async def __aenter__(self) -> "JiraClient":
|
|
213
|
+
"""Async context manager entry."""
|
|
214
|
+
return self
|
|
215
|
+
|
|
216
|
+
async def __aexit__(
|
|
217
|
+
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: Any
|
|
218
|
+
) -> None:
|
|
219
|
+
"""Async context manager exit."""
|
|
220
|
+
await self._client.aclose()
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Confluence MCP tools for interacting with Confluence Cloud."""
|
|
16
|
+
|
|
17
|
+
import logging
|
|
18
|
+
from typing import Annotated
|
|
19
|
+
|
|
20
|
+
from fastmcp.exceptions import ToolError
|
|
21
|
+
from fastmcp.tools.tool import ToolResult
|
|
22
|
+
|
|
23
|
+
from datarobot_genai.drmcp.core.mcp_instance import dr_mcp_tool
|
|
24
|
+
from datarobot_genai.drmcp.tools.clients.atlassian import get_atlassian_access_token
|
|
25
|
+
from datarobot_genai.drmcp.tools.clients.confluence import ConfluenceClient
|
|
26
|
+
|
|
27
|
+
logger = logging.getLogger(__name__)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dr_mcp_tool(tags={"confluence", "read", "get", "page"})
|
|
31
|
+
async def confluence_get_page(
|
|
32
|
+
*,
|
|
33
|
+
page_id_or_title: Annotated[str, "The ID or the exact title of the Confluence page."],
|
|
34
|
+
space_key: Annotated[
|
|
35
|
+
str | None,
|
|
36
|
+
"Required if identifying the page by title. The space key (e.g., 'PROJ').",
|
|
37
|
+
] = None,
|
|
38
|
+
) -> ToolResult | ToolError:
|
|
39
|
+
"""Retrieve the content of a specific Confluence page.
|
|
40
|
+
|
|
41
|
+
Use this tool to fetch Confluence pages by their numeric ID or by title.
|
|
42
|
+
Returns page content in HTML storage format.
|
|
43
|
+
|
|
44
|
+
Usage:
|
|
45
|
+
- By ID: page_id_or_title="856391684"
|
|
46
|
+
- By title: page_id_or_title="Meeting Notes", space_key="TEAM"
|
|
47
|
+
|
|
48
|
+
When using a page title, the space_key parameter is required.
|
|
49
|
+
"""
|
|
50
|
+
if not page_id_or_title:
|
|
51
|
+
raise ToolError("Argument validation error: 'page_id_or_title' cannot be empty.")
|
|
52
|
+
|
|
53
|
+
access_token = await get_atlassian_access_token()
|
|
54
|
+
if isinstance(access_token, ToolError):
|
|
55
|
+
raise access_token
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
async with ConfluenceClient(access_token) as client:
|
|
59
|
+
if page_id_or_title.isdigit():
|
|
60
|
+
page_response = await client.get_page_by_id(page_id_or_title)
|
|
61
|
+
else:
|
|
62
|
+
if not space_key:
|
|
63
|
+
raise ToolError(
|
|
64
|
+
"Argument validation error: "
|
|
65
|
+
"'space_key' is required when identifying a page by title."
|
|
66
|
+
)
|
|
67
|
+
page_response = await client.get_page_by_title(page_id_or_title, space_key)
|
|
68
|
+
except ValueError as e:
|
|
69
|
+
logger.error(f"Value error getting Confluence page: {e}")
|
|
70
|
+
raise ToolError(str(e))
|
|
71
|
+
except Exception as e:
|
|
72
|
+
logger.error(f"Unexpected error getting Confluence page: {e}")
|
|
73
|
+
raise ToolError(
|
|
74
|
+
f"An unexpected error occurred while getting Confluence page "
|
|
75
|
+
f"'{page_id_or_title}': {str(e)}"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return ToolResult(
|
|
79
|
+
content=f"Successfully retrieved page '{page_response.title}'.",
|
|
80
|
+
structured_content=page_response.as_flat_dict(),
|
|
81
|
+
)
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Copyright 2025 DataRobot, Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import logging
|
|
16
|
+
from typing import Annotated
|
|
17
|
+
|
|
18
|
+
from fastmcp.exceptions import ToolError
|
|
19
|
+
from fastmcp.tools.tool import ToolResult
|
|
20
|
+
|
|
21
|
+
from datarobot_genai.drmcp.core.mcp_instance import dr_mcp_tool
|
|
22
|
+
from datarobot_genai.drmcp.tools.clients.atlassian import get_atlassian_access_token
|
|
23
|
+
from datarobot_genai.drmcp.tools.clients.jira import JiraClient
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dr_mcp_tool(tags={"jira", "read", "get", "issue"})
|
|
29
|
+
async def jira_get_issue(
|
|
30
|
+
*, issue_key: Annotated[str, "The key (ID) of the Jira issue to retrieve, e.g., 'PROJ-123'."]
|
|
31
|
+
) -> ToolResult:
|
|
32
|
+
"""Retrieve all fields and details for a single Jira issue by its key."""
|
|
33
|
+
if not issue_key:
|
|
34
|
+
raise ToolError("Argument validation error: 'issue_key' cannot be empty.")
|
|
35
|
+
|
|
36
|
+
access_token = await get_atlassian_access_token()
|
|
37
|
+
if isinstance(access_token, ToolError):
|
|
38
|
+
raise access_token
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
async with JiraClient(access_token) as client:
|
|
42
|
+
issue = await client.get_jira_issue(issue_key)
|
|
43
|
+
except Exception as e:
|
|
44
|
+
logger.error(f"Unexpected error while getting Jira issue: {e}")
|
|
45
|
+
raise ToolError(
|
|
46
|
+
f"An unexpected error occurred while getting Jira issue '{issue_key}': {str(e)}"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return ToolResult(
|
|
50
|
+
content=f"Successfully retrieved details for issue '{issue_key}'.",
|
|
51
|
+
structured_content=issue.as_flat_dict(),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dr_mcp_tool(tags={"jira", "create", "add", "issue"})
|
|
56
|
+
async def jira_create_issue(
|
|
57
|
+
*,
|
|
58
|
+
project_key: Annotated[str, "The key of the project where the issue should be created."],
|
|
59
|
+
summary: Annotated[str, "A brief summary or title for the new issue."],
|
|
60
|
+
issue_type: Annotated[str, "The type of issue to create (e.g., 'Task', 'Bug', 'Story')."],
|
|
61
|
+
description: Annotated[str | None, "Detailed description of the issue."] = None,
|
|
62
|
+
) -> ToolResult:
|
|
63
|
+
"""Create a new Jira issue with mandatory project, summary, and type information."""
|
|
64
|
+
if not all([project_key, summary, issue_type]):
|
|
65
|
+
raise ToolError(
|
|
66
|
+
"Argument validation error: project_key, summary, and issue_type are required fields."
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
access_token = await get_atlassian_access_token()
|
|
70
|
+
if isinstance(access_token, ToolError):
|
|
71
|
+
raise access_token
|
|
72
|
+
|
|
73
|
+
async with JiraClient(access_token) as client:
|
|
74
|
+
# Maybe we should cache it somehow?
|
|
75
|
+
# It'll be probably constant through whole mcp server lifecycle...
|
|
76
|
+
issue_types = await client.get_jira_issue_types(project_key=project_key)
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
issue_type_id = issue_types[issue_type]
|
|
80
|
+
except KeyError:
|
|
81
|
+
possible_issue_types = ",".join(issue_types)
|
|
82
|
+
raise ToolError(
|
|
83
|
+
f"Unexpected issue type `{issue_type}`. Possible values are {possible_issue_types}."
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
async with JiraClient(access_token) as client:
|
|
88
|
+
issue_key = await client.create_jira_issue(
|
|
89
|
+
project_key=project_key,
|
|
90
|
+
summary=summary,
|
|
91
|
+
issue_type_id=issue_type_id,
|
|
92
|
+
description=description,
|
|
93
|
+
)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
logger.error(f"Unexpected error while creating Jira issue: {e}")
|
|
96
|
+
raise ToolError(f"An unexpected error occurred while creating Jira issue: {str(e)}")
|
|
97
|
+
|
|
98
|
+
return ToolResult(
|
|
99
|
+
content=f"Successfully created issue '{issue_key}'.",
|
|
100
|
+
structured_content={"newIssueKey": issue_key, "projectKey": project_key},
|
|
101
|
+
)
|