universal-mcp-applications 0.1.1__py3-none-any.whl
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.
- universal_mcp/applications/ahrefs/README.md +51 -0
- universal_mcp/applications/ahrefs/__init__.py +1 -0
- universal_mcp/applications/ahrefs/app.py +2291 -0
- universal_mcp/applications/airtable/README.md +22 -0
- universal_mcp/applications/airtable/__init__.py +1 -0
- universal_mcp/applications/airtable/app.py +479 -0
- universal_mcp/applications/apollo/README.md +44 -0
- universal_mcp/applications/apollo/__init__.py +1 -0
- universal_mcp/applications/apollo/app.py +1847 -0
- universal_mcp/applications/asana/README.md +199 -0
- universal_mcp/applications/asana/__init__.py +1 -0
- universal_mcp/applications/asana/app.py +9509 -0
- universal_mcp/applications/aws-s3/README.md +0 -0
- universal_mcp/applications/aws-s3/__init__.py +1 -0
- universal_mcp/applications/aws-s3/app.py +552 -0
- universal_mcp/applications/bill/README.md +0 -0
- universal_mcp/applications/bill/__init__.py +1 -0
- universal_mcp/applications/bill/app.py +8705 -0
- universal_mcp/applications/box/README.md +307 -0
- universal_mcp/applications/box/__init__.py +1 -0
- universal_mcp/applications/box/app.py +15987 -0
- universal_mcp/applications/braze/README.md +106 -0
- universal_mcp/applications/braze/__init__.py +1 -0
- universal_mcp/applications/braze/app.py +4754 -0
- universal_mcp/applications/cal-com-v2/README.md +150 -0
- universal_mcp/applications/cal-com-v2/__init__.py +1 -0
- universal_mcp/applications/cal-com-v2/app.py +5541 -0
- universal_mcp/applications/calendly/README.md +53 -0
- universal_mcp/applications/calendly/__init__.py +1 -0
- universal_mcp/applications/calendly/app.py +1436 -0
- universal_mcp/applications/canva/README.md +43 -0
- universal_mcp/applications/canva/__init__.py +1 -0
- universal_mcp/applications/canva/app.py +941 -0
- universal_mcp/applications/clickup/README.md +135 -0
- universal_mcp/applications/clickup/__init__.py +1 -0
- universal_mcp/applications/clickup/app.py +5009 -0
- universal_mcp/applications/coda/README.md +108 -0
- universal_mcp/applications/coda/__init__.py +1 -0
- universal_mcp/applications/coda/app.py +3671 -0
- universal_mcp/applications/confluence/README.md +198 -0
- universal_mcp/applications/confluence/__init__.py +1 -0
- universal_mcp/applications/confluence/app.py +6273 -0
- universal_mcp/applications/contentful/README.md +17 -0
- universal_mcp/applications/contentful/__init__.py +1 -0
- universal_mcp/applications/contentful/app.py +364 -0
- universal_mcp/applications/crustdata/README.md +25 -0
- universal_mcp/applications/crustdata/__init__.py +1 -0
- universal_mcp/applications/crustdata/app.py +586 -0
- universal_mcp/applications/dialpad/README.md +202 -0
- universal_mcp/applications/dialpad/__init__.py +1 -0
- universal_mcp/applications/dialpad/app.py +5949 -0
- universal_mcp/applications/digitalocean/README.md +463 -0
- universal_mcp/applications/digitalocean/__init__.py +1 -0
- universal_mcp/applications/digitalocean/app.py +20835 -0
- universal_mcp/applications/domain-checker/README.md +13 -0
- universal_mcp/applications/domain-checker/__init__.py +1 -0
- universal_mcp/applications/domain-checker/app.py +265 -0
- universal_mcp/applications/e2b/README.md +12 -0
- universal_mcp/applications/e2b/__init__.py +1 -0
- universal_mcp/applications/e2b/app.py +187 -0
- universal_mcp/applications/elevenlabs/README.md +88 -0
- universal_mcp/applications/elevenlabs/__init__.py +1 -0
- universal_mcp/applications/elevenlabs/app.py +3235 -0
- universal_mcp/applications/exa/README.md +15 -0
- universal_mcp/applications/exa/__init__.py +1 -0
- universal_mcp/applications/exa/app.py +221 -0
- universal_mcp/applications/falai/README.md +17 -0
- universal_mcp/applications/falai/__init__.py +1 -0
- universal_mcp/applications/falai/app.py +331 -0
- universal_mcp/applications/figma/README.md +49 -0
- universal_mcp/applications/figma/__init__.py +1 -0
- universal_mcp/applications/figma/app.py +1090 -0
- universal_mcp/applications/firecrawl/README.md +20 -0
- universal_mcp/applications/firecrawl/__init__.py +1 -0
- universal_mcp/applications/firecrawl/app.py +514 -0
- universal_mcp/applications/fireflies/README.md +25 -0
- universal_mcp/applications/fireflies/__init__.py +1 -0
- universal_mcp/applications/fireflies/app.py +506 -0
- universal_mcp/applications/fpl/README.md +23 -0
- universal_mcp/applications/fpl/__init__.py +1 -0
- universal_mcp/applications/fpl/app.py +1327 -0
- universal_mcp/applications/fpl/utils/api.py +142 -0
- universal_mcp/applications/fpl/utils/fixtures.py +629 -0
- universal_mcp/applications/fpl/utils/helper.py +982 -0
- universal_mcp/applications/fpl/utils/league_utils.py +546 -0
- universal_mcp/applications/fpl/utils/position_utils.py +68 -0
- universal_mcp/applications/ghost-content/README.md +25 -0
- universal_mcp/applications/ghost-content/__init__.py +1 -0
- universal_mcp/applications/ghost-content/app.py +654 -0
- universal_mcp/applications/github/README.md +1049 -0
- universal_mcp/applications/github/__init__.py +1 -0
- universal_mcp/applications/github/app.py +50600 -0
- universal_mcp/applications/gong/README.md +63 -0
- universal_mcp/applications/gong/__init__.py +1 -0
- universal_mcp/applications/gong/app.py +2297 -0
- universal_mcp/applications/google-ads/README.md +0 -0
- universal_mcp/applications/google-ads/__init__.py +1 -0
- universal_mcp/applications/google-ads/app.py +23 -0
- universal_mcp/applications/google-calendar/README.md +21 -0
- universal_mcp/applications/google-calendar/__init__.py +1 -0
- universal_mcp/applications/google-calendar/app.py +574 -0
- universal_mcp/applications/google-docs/README.md +25 -0
- universal_mcp/applications/google-docs/__init__.py +1 -0
- universal_mcp/applications/google-docs/app.py +760 -0
- universal_mcp/applications/google-drive/README.md +68 -0
- universal_mcp/applications/google-drive/__init__.py +1 -0
- universal_mcp/applications/google-drive/app.py +4936 -0
- universal_mcp/applications/google-gemini/README.md +25 -0
- universal_mcp/applications/google-gemini/__init__.py +1 -0
- universal_mcp/applications/google-gemini/app.py +663 -0
- universal_mcp/applications/google-mail/README.md +31 -0
- universal_mcp/applications/google-mail/__init__.py +1 -0
- universal_mcp/applications/google-mail/app.py +1354 -0
- universal_mcp/applications/google-searchconsole/README.md +21 -0
- universal_mcp/applications/google-searchconsole/__init__.py +1 -0
- universal_mcp/applications/google-searchconsole/app.py +320 -0
- universal_mcp/applications/google-sheet/README.md +36 -0
- universal_mcp/applications/google-sheet/__init__.py +1 -0
- universal_mcp/applications/google-sheet/app.py +1941 -0
- universal_mcp/applications/hashnode/README.md +20 -0
- universal_mcp/applications/hashnode/__init__.py +1 -0
- universal_mcp/applications/hashnode/app.py +455 -0
- universal_mcp/applications/heygen/README.md +44 -0
- universal_mcp/applications/heygen/__init__.py +1 -0
- universal_mcp/applications/heygen/app.py +961 -0
- universal_mcp/applications/http-tools/README.md +16 -0
- universal_mcp/applications/http-tools/__init__.py +1 -0
- universal_mcp/applications/http-tools/app.py +153 -0
- universal_mcp/applications/hubspot/README.md +239 -0
- universal_mcp/applications/hubspot/__init__.py +1 -0
- universal_mcp/applications/hubspot/app.py +416 -0
- universal_mcp/applications/jira/README.md +600 -0
- universal_mcp/applications/jira/__init__.py +1 -0
- universal_mcp/applications/jira/app.py +28804 -0
- universal_mcp/applications/klaviyo/README.md +313 -0
- universal_mcp/applications/klaviyo/__init__.py +1 -0
- universal_mcp/applications/klaviyo/app.py +11236 -0
- universal_mcp/applications/linkedin/README.md +15 -0
- universal_mcp/applications/linkedin/__init__.py +1 -0
- universal_mcp/applications/linkedin/app.py +243 -0
- universal_mcp/applications/mailchimp/README.md +281 -0
- universal_mcp/applications/mailchimp/__init__.py +1 -0
- universal_mcp/applications/mailchimp/app.py +10937 -0
- universal_mcp/applications/markitdown/README.md +12 -0
- universal_mcp/applications/markitdown/__init__.py +1 -0
- universal_mcp/applications/markitdown/app.py +63 -0
- universal_mcp/applications/miro/README.md +151 -0
- universal_mcp/applications/miro/__init__.py +1 -0
- universal_mcp/applications/miro/app.py +5429 -0
- universal_mcp/applications/ms-teams/README.md +42 -0
- universal_mcp/applications/ms-teams/__init__.py +1 -0
- universal_mcp/applications/ms-teams/app.py +1823 -0
- universal_mcp/applications/neon/README.md +74 -0
- universal_mcp/applications/neon/__init__.py +1 -0
- universal_mcp/applications/neon/app.py +2018 -0
- universal_mcp/applications/notion/README.md +30 -0
- universal_mcp/applications/notion/__init__.py +1 -0
- universal_mcp/applications/notion/app.py +527 -0
- universal_mcp/applications/openai/README.md +22 -0
- universal_mcp/applications/openai/__init__.py +1 -0
- universal_mcp/applications/openai/app.py +759 -0
- universal_mcp/applications/outlook/README.md +20 -0
- universal_mcp/applications/outlook/__init__.py +1 -0
- universal_mcp/applications/outlook/app.py +444 -0
- universal_mcp/applications/perplexity/README.md +12 -0
- universal_mcp/applications/perplexity/__init__.py +1 -0
- universal_mcp/applications/perplexity/app.py +65 -0
- universal_mcp/applications/pipedrive/README.md +284 -0
- universal_mcp/applications/pipedrive/__init__.py +1 -0
- universal_mcp/applications/pipedrive/app.py +12924 -0
- universal_mcp/applications/posthog/README.md +132 -0
- universal_mcp/applications/posthog/__init__.py +1 -0
- universal_mcp/applications/posthog/app.py +7125 -0
- universal_mcp/applications/reddit/README.md +135 -0
- universal_mcp/applications/reddit/__init__.py +1 -0
- universal_mcp/applications/reddit/app.py +4652 -0
- universal_mcp/applications/replicate/README.md +18 -0
- universal_mcp/applications/replicate/__init__.py +1 -0
- universal_mcp/applications/replicate/app.py +495 -0
- universal_mcp/applications/resend/README.md +40 -0
- universal_mcp/applications/resend/__init__.py +1 -0
- universal_mcp/applications/resend/app.py +881 -0
- universal_mcp/applications/retell/README.md +21 -0
- universal_mcp/applications/retell/__init__.py +1 -0
- universal_mcp/applications/retell/app.py +333 -0
- universal_mcp/applications/rocketlane/README.md +70 -0
- universal_mcp/applications/rocketlane/__init__.py +1 -0
- universal_mcp/applications/rocketlane/app.py +4346 -0
- universal_mcp/applications/semanticscholar/README.md +25 -0
- universal_mcp/applications/semanticscholar/__init__.py +1 -0
- universal_mcp/applications/semanticscholar/app.py +482 -0
- universal_mcp/applications/semrush/README.md +44 -0
- universal_mcp/applications/semrush/__init__.py +1 -0
- universal_mcp/applications/semrush/app.py +2081 -0
- universal_mcp/applications/sendgrid/README.md +362 -0
- universal_mcp/applications/sendgrid/__init__.py +1 -0
- universal_mcp/applications/sendgrid/app.py +9752 -0
- universal_mcp/applications/sentry/README.md +186 -0
- universal_mcp/applications/sentry/__init__.py +1 -0
- universal_mcp/applications/sentry/app.py +7471 -0
- universal_mcp/applications/serpapi/README.md +14 -0
- universal_mcp/applications/serpapi/__init__.py +1 -0
- universal_mcp/applications/serpapi/app.py +293 -0
- universal_mcp/applications/sharepoint/README.md +0 -0
- universal_mcp/applications/sharepoint/__init__.py +1 -0
- universal_mcp/applications/sharepoint/app.py +215 -0
- universal_mcp/applications/shopify/README.md +321 -0
- universal_mcp/applications/shopify/__init__.py +1 -0
- universal_mcp/applications/shopify/app.py +15392 -0
- universal_mcp/applications/shortcut/README.md +128 -0
- universal_mcp/applications/shortcut/__init__.py +1 -0
- universal_mcp/applications/shortcut/app.py +4478 -0
- universal_mcp/applications/slack/README.md +0 -0
- universal_mcp/applications/slack/__init__.py +1 -0
- universal_mcp/applications/slack/app.py +570 -0
- universal_mcp/applications/spotify/README.md +91 -0
- universal_mcp/applications/spotify/__init__.py +1 -0
- universal_mcp/applications/spotify/app.py +2526 -0
- universal_mcp/applications/supabase/README.md +87 -0
- universal_mcp/applications/supabase/__init__.py +1 -0
- universal_mcp/applications/supabase/app.py +2970 -0
- universal_mcp/applications/tavily/README.md +12 -0
- universal_mcp/applications/tavily/__init__.py +1 -0
- universal_mcp/applications/tavily/app.py +51 -0
- universal_mcp/applications/trello/README.md +266 -0
- universal_mcp/applications/trello/__init__.py +1 -0
- universal_mcp/applications/trello/app.py +10875 -0
- universal_mcp/applications/twillo/README.md +0 -0
- universal_mcp/applications/twillo/__init__.py +1 -0
- universal_mcp/applications/twillo/app.py +269 -0
- universal_mcp/applications/twitter/README.md +100 -0
- universal_mcp/applications/twitter/__init__.py +1 -0
- universal_mcp/applications/twitter/api_segments/__init__.py +0 -0
- universal_mcp/applications/twitter/api_segments/api_segment_base.py +51 -0
- universal_mcp/applications/twitter/api_segments/compliance_api.py +122 -0
- universal_mcp/applications/twitter/api_segments/dm_conversations_api.py +255 -0
- universal_mcp/applications/twitter/api_segments/dm_events_api.py +140 -0
- universal_mcp/applications/twitter/api_segments/likes_api.py +159 -0
- universal_mcp/applications/twitter/api_segments/lists_api.py +395 -0
- universal_mcp/applications/twitter/api_segments/openapi_json_api.py +34 -0
- universal_mcp/applications/twitter/api_segments/spaces_api.py +309 -0
- universal_mcp/applications/twitter/api_segments/trends_api.py +40 -0
- universal_mcp/applications/twitter/api_segments/tweets_api.py +1403 -0
- universal_mcp/applications/twitter/api_segments/usage_api.py +40 -0
- universal_mcp/applications/twitter/api_segments/users_api.py +1498 -0
- universal_mcp/applications/twitter/app.py +46 -0
- universal_mcp/applications/unipile/README.md +28 -0
- universal_mcp/applications/unipile/__init__.py +1 -0
- universal_mcp/applications/unipile/app.py +829 -0
- universal_mcp/applications/whatsapp/README.md +23 -0
- universal_mcp/applications/whatsapp/__init__.py +1 -0
- universal_mcp/applications/whatsapp/app.py +595 -0
- universal_mcp/applications/whatsapp-business/README.md +34 -0
- universal_mcp/applications/whatsapp-business/__init__.py +1 -0
- universal_mcp/applications/whatsapp-business/app.py +1065 -0
- universal_mcp/applications/wrike/README.md +46 -0
- universal_mcp/applications/wrike/__init__.py +1 -0
- universal_mcp/applications/wrike/app.py +1583 -0
- universal_mcp/applications/youtube/README.md +57 -0
- universal_mcp/applications/youtube/__init__.py +1 -0
- universal_mcp/applications/youtube/app.py +1696 -0
- universal_mcp/applications/zenquotes/README.md +12 -0
- universal_mcp/applications/zenquotes/__init__.py +1 -0
- universal_mcp/applications/zenquotes/app.py +31 -0
- universal_mcp_applications-0.1.1.dist-info/METADATA +172 -0
- universal_mcp_applications-0.1.1.dist-info/RECORD +268 -0
- universal_mcp_applications-0.1.1.dist-info/WHEEL +4 -0
- universal_mcp_applications-0.1.1.dist-info/licenses/LICENSE +21 -0
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .app import TwillioApp
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from loguru import logger
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from twilio.rest import Client as TwilioClient
|
|
9
|
+
except ImportError:
|
|
10
|
+
TwilioClient = None
|
|
11
|
+
logger.error(
|
|
12
|
+
"Twilio SDK is not installed. Please install 'twilio' to use TwilioApp."
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from universal_mcp.applications.application import APIApplication
|
|
16
|
+
from universal_mcp.exceptions import NotAuthorizedError, ToolError
|
|
17
|
+
from universal_mcp.integrations import Integration
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class TwillioApp(APIApplication):
|
|
21
|
+
"""
|
|
22
|
+
Application for interacting with the Twilio Messaging API using the official Python SDK.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def __init__(self, integration: Integration, **kwargs: Any) -> None:
|
|
26
|
+
super().__init__(name="twillio", integration=integration, **kwargs)
|
|
27
|
+
self.base_url = "https://api.twilio.com/2010-04-01"
|
|
28
|
+
self._twilio_client: Any | None = None
|
|
29
|
+
self._account_sid: str | None = None
|
|
30
|
+
self._auth_token: str | None = None
|
|
31
|
+
if TwilioClient is None:
|
|
32
|
+
logger.warning(
|
|
33
|
+
"Twilio SDK is not available. Twilio tools will not function."
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def account_sid(self) -> str:
|
|
38
|
+
"""
|
|
39
|
+
Retrieves and caches the Twilio Account SID from the integration credentials.
|
|
40
|
+
"""
|
|
41
|
+
if self._account_sid is None:
|
|
42
|
+
if not self.integration:
|
|
43
|
+
raise NotAuthorizedError("Integration not configured for Twilio App.")
|
|
44
|
+
try:
|
|
45
|
+
credentials = self.integration.get_credentials()
|
|
46
|
+
except Exception as e:
|
|
47
|
+
raise NotAuthorizedError(f"Failed to get Twilio credentials: {e}")
|
|
48
|
+
|
|
49
|
+
sid = (
|
|
50
|
+
credentials.get("account_sid")
|
|
51
|
+
or credentials.get("ACCOUNT_SID")
|
|
52
|
+
or credentials.get("TWILIO_ACCOUNT_SID")
|
|
53
|
+
)
|
|
54
|
+
if not sid:
|
|
55
|
+
raise NotAuthorizedError(
|
|
56
|
+
"Twilio Account SID is missing. Please set it in the integration."
|
|
57
|
+
)
|
|
58
|
+
self._account_sid = sid
|
|
59
|
+
return self._account_sid
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def auth_token(self) -> str:
|
|
63
|
+
"""
|
|
64
|
+
Retrieves and caches the Twilio Auth Token from the integration credentials.
|
|
65
|
+
"""
|
|
66
|
+
if self._auth_token is None:
|
|
67
|
+
if not self.integration:
|
|
68
|
+
raise NotAuthorizedError("Integration not configured for Twilio App.")
|
|
69
|
+
try:
|
|
70
|
+
credentials = self.integration.get_credentials()
|
|
71
|
+
except Exception as e:
|
|
72
|
+
raise NotAuthorizedError(f"Failed to get Twilio credentials: {e}")
|
|
73
|
+
|
|
74
|
+
token = (
|
|
75
|
+
credentials.get("auth_token")
|
|
76
|
+
or credentials.get("AUTH_TOKEN")
|
|
77
|
+
or credentials.get("TWILIO_AUTH_TOKEN")
|
|
78
|
+
)
|
|
79
|
+
if not token:
|
|
80
|
+
raise NotAuthorizedError(
|
|
81
|
+
"Twilio Auth Token is missing. Please set it in the integration."
|
|
82
|
+
)
|
|
83
|
+
self._auth_token = token
|
|
84
|
+
return self._auth_token
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def twilio_client(self) -> Any:
|
|
88
|
+
"""
|
|
89
|
+
Returns a cached Twilio Client instance.
|
|
90
|
+
"""
|
|
91
|
+
if self._twilio_client is None:
|
|
92
|
+
if TwilioClient is None:
|
|
93
|
+
raise ToolError("Twilio SDK is not installed.")
|
|
94
|
+
self._twilio_client = TwilioClient(self.account_sid, self.auth_token)
|
|
95
|
+
return self._twilio_client
|
|
96
|
+
|
|
97
|
+
def create_message(self, from_: str, to: str, body: str) -> dict[str, Any]:
|
|
98
|
+
"""
|
|
99
|
+
Sends a new SMS or MMS message using Twilio.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
from_: The Twilio phone number (in E.164 format) to send the message from.
|
|
103
|
+
to: The recipient's phone number (in E.164 format).
|
|
104
|
+
body: The content of the message.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
A dictionary containing the Twilio message resource details.
|
|
108
|
+
|
|
109
|
+
Raises:
|
|
110
|
+
NotAuthorizedError: If credentials are missing or invalid.
|
|
111
|
+
ToolError: If the SDK is not installed or sending fails.
|
|
112
|
+
|
|
113
|
+
Tags:
|
|
114
|
+
create, message, sms, mms, send, twilio, api, important
|
|
115
|
+
"""
|
|
116
|
+
try:
|
|
117
|
+
message = self.twilio_client.messages.create(
|
|
118
|
+
from_=from_,
|
|
119
|
+
to=to,
|
|
120
|
+
body=body,
|
|
121
|
+
)
|
|
122
|
+
# Convert the Twilio MessageInstance to a dict
|
|
123
|
+
return {
|
|
124
|
+
"sid": message.sid,
|
|
125
|
+
"status": message.status,
|
|
126
|
+
"body": message.body,
|
|
127
|
+
"from": message.from_,
|
|
128
|
+
"to": message.to,
|
|
129
|
+
"date_created": str(message.date_created),
|
|
130
|
+
"date_sent": str(message.date_sent),
|
|
131
|
+
"date_updated": str(message.date_updated),
|
|
132
|
+
"error_code": message.error_code,
|
|
133
|
+
"error_message": message.error_message,
|
|
134
|
+
}
|
|
135
|
+
except Exception as e:
|
|
136
|
+
if "Authenticate" in str(e) or "401" in str(e):
|
|
137
|
+
raise NotAuthorizedError(f"Twilio authentication failed: {e}")
|
|
138
|
+
raise ToolError(f"Failed to send message: {e}")
|
|
139
|
+
|
|
140
|
+
def fetch_message(self, message_sid: str) -> dict[str, Any]:
|
|
141
|
+
"""
|
|
142
|
+
Fetches the details of a specific message by its SID.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
message_sid: The unique SID of the message (starts with 'SM').
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
A dictionary containing the message details.
|
|
149
|
+
|
|
150
|
+
Raises:
|
|
151
|
+
NotAuthorizedError: If credentials are missing or invalid.
|
|
152
|
+
ToolError: If the SDK is not installed or fetch fails.
|
|
153
|
+
|
|
154
|
+
Tags:
|
|
155
|
+
fetch, message, sms, mms, read, twilio, api, important
|
|
156
|
+
"""
|
|
157
|
+
try:
|
|
158
|
+
message = self.twilio_client.messages(message_sid).fetch()
|
|
159
|
+
return {
|
|
160
|
+
"sid": message.sid,
|
|
161
|
+
"status": message.status,
|
|
162
|
+
"body": message.body,
|
|
163
|
+
"from": message.from_,
|
|
164
|
+
"to": message.to,
|
|
165
|
+
"date_created": str(message.date_created),
|
|
166
|
+
"date_sent": str(message.date_sent),
|
|
167
|
+
"date_updated": str(message.date_updated),
|
|
168
|
+
"error_code": message.error_code,
|
|
169
|
+
"error_message": message.error_message,
|
|
170
|
+
}
|
|
171
|
+
except Exception as e:
|
|
172
|
+
if "Authenticate" in str(e) or "401" in str(e):
|
|
173
|
+
raise NotAuthorizedError(f"Twilio authentication failed: {e}")
|
|
174
|
+
raise ToolError(f"Failed to fetch message: {e}")
|
|
175
|
+
|
|
176
|
+
def list_messages(
|
|
177
|
+
self,
|
|
178
|
+
limit: int = 20,
|
|
179
|
+
date_sent_before: datetime | None = None,
|
|
180
|
+
date_sent_after: datetime | None = None,
|
|
181
|
+
) -> list[dict[str, Any]]:
|
|
182
|
+
"""
|
|
183
|
+
Lists messages from your Twilio account, optionally filtered by date.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
limit: The maximum number of messages to return (default: 20).
|
|
187
|
+
date_sent_before: Only include messages sent before this datetime (optional).
|
|
188
|
+
date_sent_after: Only include messages sent after this datetime (optional).
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
A list of dictionaries, each representing a message.
|
|
192
|
+
|
|
193
|
+
Raises:
|
|
194
|
+
NotAuthorizedError: If credentials are missing or invalid.
|
|
195
|
+
ToolError: If the SDK is not installed or listing fails.
|
|
196
|
+
|
|
197
|
+
Tags:
|
|
198
|
+
list, message, sms, mms, read, twilio, api, important
|
|
199
|
+
"""
|
|
200
|
+
try:
|
|
201
|
+
params = {
|
|
202
|
+
"limit": limit,
|
|
203
|
+
}
|
|
204
|
+
if date_sent_before:
|
|
205
|
+
params["date_sent_before"] = date_sent_before
|
|
206
|
+
if date_sent_after:
|
|
207
|
+
params["date_sent_after"] = date_sent_after
|
|
208
|
+
|
|
209
|
+
messages = self.twilio_client.messages.list(**params)
|
|
210
|
+
result = []
|
|
211
|
+
for msg in messages:
|
|
212
|
+
result.append(
|
|
213
|
+
{
|
|
214
|
+
"sid": msg.sid,
|
|
215
|
+
"status": msg.status,
|
|
216
|
+
"body": msg.body,
|
|
217
|
+
"from": msg.from_,
|
|
218
|
+
"to": msg.to,
|
|
219
|
+
"date_created": str(msg.date_created),
|
|
220
|
+
"date_sent": str(msg.date_sent),
|
|
221
|
+
"date_updated": str(msg.date_updated),
|
|
222
|
+
"error_code": msg.error_code,
|
|
223
|
+
"error_message": msg.error_message,
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
return result
|
|
227
|
+
except Exception as e:
|
|
228
|
+
if "Authenticate" in str(e) or "401" in str(e):
|
|
229
|
+
raise NotAuthorizedError(f"Twilio authentication failed: {e}")
|
|
230
|
+
raise ToolError(f"Failed to list messages: {e}")
|
|
231
|
+
|
|
232
|
+
def delete_message(self, message_sid: str) -> bool:
|
|
233
|
+
"""
|
|
234
|
+
Deletes a specific message from your Twilio account.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
message_sid: The unique SID of the message to delete (starts with 'SM').
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
True if the message was deleted successfully, False otherwise.
|
|
241
|
+
|
|
242
|
+
Raises:
|
|
243
|
+
NotAuthorizedError: If credentials are missing or invalid.
|
|
244
|
+
ToolError: If the SDK is not installed or deletion fails.
|
|
245
|
+
|
|
246
|
+
Tags:
|
|
247
|
+
delete, message, sms, mms, remove, twilio, api, important
|
|
248
|
+
"""
|
|
249
|
+
try:
|
|
250
|
+
result = self.twilio_client.messages(message_sid).delete()
|
|
251
|
+
return bool(result)
|
|
252
|
+
except Exception as e:
|
|
253
|
+
if "Authenticate" in str(e) or "401" in str(e):
|
|
254
|
+
raise NotAuthorizedError(f"Twilio authentication failed: {e}")
|
|
255
|
+
raise ToolError(f"Failed to delete message: {e}")
|
|
256
|
+
|
|
257
|
+
def list_tools(self) -> list[Callable]:
|
|
258
|
+
"""
|
|
259
|
+
Lists all public tools provided by the TwilioApp.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
A list of callable tool methods.
|
|
263
|
+
"""
|
|
264
|
+
return [
|
|
265
|
+
self.create_message,
|
|
266
|
+
self.fetch_message,
|
|
267
|
+
self.list_messages,
|
|
268
|
+
self.delete_message,
|
|
269
|
+
]
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# TwitterApp MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP Server for the TwitterApp API.
|
|
4
|
+
|
|
5
|
+
## 🛠️ Tool List
|
|
6
|
+
|
|
7
|
+
This is automatically generated from OpenAPI schema for the TwitterApp API.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
| Tool | Description |
|
|
11
|
+
|------|-------------|
|
|
12
|
+
| `list_batch_compliance_jobs` | Retrieves a list of compliance jobs based on the specified job type, with optional filtering by status. |
|
|
13
|
+
| `create_batch_compliance_job` | Creates a new compliance job using JSON data in the request body and authenticates the request using a Bearer token. |
|
|
14
|
+
| `get_batch_compliance_job` | Retrieves information about a compliance job by its ID using the BearerToken for authentication. |
|
|
15
|
+
| `dm_conversation_id_create` | Creates a new group Direct Message conversation and sends an initial message to the specified participants. |
|
|
16
|
+
| `get_dm_conversations_with_participant_id_dm_events` | Retrieves a list of direct message events for a conversation with a specific participant, allowing for optional filtering by event types and pagination. |
|
|
17
|
+
| `get_dm_conversations_id_dm_events` | Retrieves a list of direct message events for a specified conversation ID, allowing for optional filtering by event types and pagination. |
|
|
18
|
+
| `get_dm_events` | Retrieves a list of direct message events with optional filtering by event types, pagination, and field expansions for media, users, tweets, and DM event details. |
|
|
19
|
+
| `dm_event_delete` | Deletes a DM event by its ID using the DELETE method, requiring authentication via OAuth2UserToken with "dm.read" and "dm.write" scopes or UserToken. |
|
|
20
|
+
| `get_dm_events_by_id` | Retrieves detailed information about a specific direct message event by its event ID with optional expansions and field selections. |
|
|
21
|
+
| `get_likes_compliance_stream` | Streams compliance-related likes data using the GET method, allowing optional filtering by backfill minutes and time range. |
|
|
22
|
+
| `likes_firehose_stream` | Streams a real-time firehose of likes data filtered by partition and optional time range parameters, including expanded tweet and user fields, using Bearer Token authentication. |
|
|
23
|
+
| `likes_sample10_stream` | Streams a sample of 10 likes using the GET method, optionally filtering by backfill minutes, partition, start and end times, and including specific tweet and user fields. |
|
|
24
|
+
| `list_id_create` | Creates a new Twitter list using the X API v2 and returns the newly created list's details. |
|
|
25
|
+
| `list_id_delete` | Deletes a list specified by its ID using the DELETE method. |
|
|
26
|
+
| `list_id_get` | Retrieves detailed information about a specific Twitter List by its unique identifier, including optional expansions and fields for lists and users. |
|
|
27
|
+
| `list_id_update` | Updates a list specified by the ID using the provided JSON payload, authenticating with OAuth2 or user tokens. |
|
|
28
|
+
| `list_get_followers` | Retrieves a list of users who follow a specified Twitter list using the list ID, with optional parameters for pagination and user data customization. |
|
|
29
|
+
| `list_get_members` | Retrieves a list of User objects that are members of a specified Twitter List by the provided List ID. |
|
|
30
|
+
| `list_add_member` | Adds one or more members to a specified list by list ID using the POST method. |
|
|
31
|
+
| `list_remove_member` | Removes a member from a list using the provided list ID and user ID, requiring appropriate permissions for the operation. |
|
|
32
|
+
| `lists_id_tweets` | Retrieves a list of tweets for a specified list by ID using the "GET" method, allowing optional parameters for pagination and field customization. |
|
|
33
|
+
| `get_open_api_spec` | Retrieves the OpenAPI JSON file at the specified path "/2/openapi.json" using the GET method. |
|
|
34
|
+
| `find_spaces_by_ids` | Retrieves detailed information about specified spaces using the "GET" method, allowing customization through parameters such as space IDs, space fields, space expansions, user fields, and topic fields, while requiring authentication via Bearer or OAuth2 tokens for authorized access. |
|
|
35
|
+
| `find_spaces_by_creator_ids` | Retrieves a list of spaces by their creator IDs using the specified user IDs, with optional filtering by space fields, space expansions, user fields, and topic fields. |
|
|
36
|
+
| `search_spaces` | Searches for spaces using the specified query and optional filters like state, and returns the results with customizable fields and expansions. |
|
|
37
|
+
| `find_space_by_id` | Retrieves details about a specific space by its ID, allowing optional customization through space fields, space expansions, user fields, and topic fields, using a Bearer or OAuth2 token for authentication. |
|
|
38
|
+
| `space_buyers` | Retrieves a list of buyers for a specific space using the "GET" method, allowing optional pagination and customization of returned user and tweet fields. |
|
|
39
|
+
| `space_tweets` | Retrieves a list of tweets from a specified Twitter Space by its ID, with optional parameters to customize the fields and expansions included in the response. |
|
|
40
|
+
| `get_trends` | Retrieves trending information by WOEID (Where On Earth ID) using the specified trend fields and returns a response with a valid Bearer token. |
|
|
41
|
+
| `find_tweets_by_id` | Retrieves one or more Tweets by their IDs and returns associated details, supporting optional parameters for specifying additional fields and expansions. |
|
|
42
|
+
| `create_tweet` | Creates a new tweet using the Twitter API v2, requiring an application/json payload and OAuth2 user token for authentication, and returns a 201 status upon successful creation. |
|
|
43
|
+
| `get_tweets_compliance_stream` | Streams compliance events for tweets in real-time, allowing for the retrieval of events such as post deletions, edits, and withholdings, as well as user account changes, using parameters like partition, backfill_minutes, start_time, and end_time. |
|
|
44
|
+
| `tweet_counts_full_archive_search` | Retrieves the full-archive count of tweets for a specified query using the "/2/tweets/counts/all" endpoint, allowing optional filtering by start and end times, granularity, and pagination. |
|
|
45
|
+
| `tweet_counts_recent_search` | Retrieves the count of recent Tweets that match a search query over the last seven days, using the "GET" method with optional parameters for specifying start and end times, granularity, and pagination. |
|
|
46
|
+
| `get_tweets_firehose_stream` | Streams all tweets in real-time using the Firehose API, allowing parameters such as partition, backfill minutes, start and end time, and various field expansions to customize the data retrieved, which requires authentication via a Bearer Token. |
|
|
47
|
+
| `get_tweets_firehose_stream_lang_en` | Connects to the Twitter Firehose streaming API to receive a real-time stream of English-language tweets with optional filtering and data field expansions. |
|
|
48
|
+
| `get_tweets_firehose_stream_lang_ja` | Retrieves a stream of Tweets in Japanese using the Firehose API, allowing for real-time access to a high-volume stream of Tweets based on specified parameters such as partitions and optional backfill minutes, start and end times, and customizable fields for Tweets, users, and media. |
|
|
49
|
+
| `get_tweets_firehose_stream_lang_ko` | Streams real-time tweets in Korean from the Twitter firehose, allowing for optional backfill, specific partitions, and customizable start and end times, with support for various tweet, media, poll, user, and place fields. |
|
|
50
|
+
| `get_tweets_firehose_stream_lang_pt` | Streams real-time Tweets in Portuguese using the Firehose API, allowing for filtering by specific parameters such as tweet fields, expansions, media, polls, users, and places, and requires a partition number for the stream. |
|
|
51
|
+
| `get_tweets_label_stream` | Streams tweets labeled with a specific identifier in real-time using the Twitter API, allowing for optional parameters to specify backfill minutes, start time, and end time, and requires authentication via a Bearer Token. |
|
|
52
|
+
| `sample_stream` | Retrieves a real-time sampled stream of public Tweets with optional parameters to specify Tweet, user, media, poll, and place fields, supporting backfill for missed data. |
|
|
53
|
+
| `get_tweets_sample10_stream` | Streams a random sample of 10% of all Tweets in real-time, allowing optional filtering by specifying additional parameters such as backfill minutes, partition, start and end times, and various field expansions for tweets, media, polls, users, and places. |
|
|
54
|
+
| `tweets_fullarchive_search` | Retrieves and returns a list of historical Tweets matching a specified query, allowing for filtering by time range, tweet ID, and other parameters. |
|
|
55
|
+
| `tweets_recent_search` | Retrieves recent tweets based on a specified search query, allowing for optional filtering by time range and additional parameters such as tweet fields, expansions, and user details. |
|
|
56
|
+
| `search_stream` | Streams tweets based on predefined rules using the Twitter API v2, allowing for real-time filtering and retrieval of tweets with optional parameters for backfill minutes, start and end times, and various tweet, media, poll, user, and place fields. |
|
|
57
|
+
| `get_rules` | Retrieves the active stream filtering rules for a user's Twitter API v2 filtered stream, optionally filtered by rule IDs, with support for pagination and maximum results. |
|
|
58
|
+
| `get_rule_count` | Retrieves the counts of Tweets matching specific search rules using the "GET" method, providing a way to analyze the volume of Tweets based on predefined criteria. |
|
|
59
|
+
| `delete_tweet_by_id` | Deletes a specified Tweet by its ID on behalf of an authenticated user. |
|
|
60
|
+
| `find_tweet_by_id` | Retrieves detailed information about a single Tweet specified by its unique ID, with optional expansions for fields related to the Tweet, user, media, polls, and places. |
|
|
61
|
+
| `tweets_id_liking_users` | Retrieves a list of users who have liked a specified tweet using the provided tweet ID. |
|
|
62
|
+
| `find_tweets_that_quote_atweet` | Retrieves a list of quote Tweets for a specified Tweet ID, allowing for optional parameters to customize the results with fields like tweet fields, media fields, and user expansions, and supports pagination for handling large responses. |
|
|
63
|
+
| `tweets_id_retweeting_users` | Retrieves a list of User objects representing users who have retweeted the Tweet specified by the given Tweet ID. |
|
|
64
|
+
| `find_tweets_that_retweet_atweet` | Retrieves a list of retweets for a specified Tweet ID, optionally allowing for pagination and customization of returned fields via query parameters. |
|
|
65
|
+
| `hide_reply_by_id` | Hides or unhides a reply to a specified Tweet by its tweet_id. |
|
|
66
|
+
| `get_usage_tweets` | Retrieves and returns Twitter usage data using the specified fields and optionally filters by a number of days. |
|
|
67
|
+
| `find_users_by_id` | Retrieves information about one or more users specified by their IDs, allowing for customization with user fields and expansions. |
|
|
68
|
+
| `find_users_by_username` | Retrieves information about one or more users specified by their usernames using the Twitter API, allowing optional specification of additional user fields and expansions. |
|
|
69
|
+
| `find_user_by_username` | Retrieves information about a user specified by their username, optionally including additional fields and expansions, using the "GET" method with authentication. |
|
|
70
|
+
| `get_users_compliance_stream` | Streams compliance data for users using the "GET" method, supporting optional backfill minutes, start and end times, and requiring a partition parameter. |
|
|
71
|
+
| `find_my_user` | Retrieves detailed information about the authenticated user, including optional expansions and fields for user and tweet data. |
|
|
72
|
+
| `search_user_by_query` | Searches for users using a query string, returning a list of matching users with optional fields for user details, expansions, and related tweet fields. |
|
|
73
|
+
| `find_user_by_id` | Retrieves information about a user specified by their ID, with optional parameters for specifying additional user fields, expansions, and tweet fields. |
|
|
74
|
+
| `users_id_blocking` | Retrieves a list of user objects that are blocked by the specified user ID, allowing for additional fields and expansions to be specified. |
|
|
75
|
+
| `get_users_id_bookmarks` | Retrieves a list of bookmarks for a user with the specified ID, allowing optional pagination and customization of returned fields. |
|
|
76
|
+
| `post_users_id_bookmarks` | Adds bookmarks for a specified user using the provided JSON data and returns a successful response upon completion. |
|
|
77
|
+
| `users_id_bookmarks_delete` | Deletes a bookmarked tweet for a specified user using the "DELETE" method. |
|
|
78
|
+
| `user_followed_lists` | Retrieves a list of Twitter lists followed by a specified user, with optional parameters for pagination, list fields, and user fields. |
|
|
79
|
+
| `list_user_follow` | Adds a Twitter user to a list of followed lists using the Twitter API and returns a status message. |
|
|
80
|
+
| `list_user_unfollow` | Deletes the specified list followed by the user identified by the given user ID and list ID. |
|
|
81
|
+
| `users_id_followers` | Retrieves a list of users who follow a specified user using the Twitter API, with optional parameters for result pagination and additional user or tweet fields. |
|
|
82
|
+
| `users_id_following` | Retrieves a list of users followed by the specified user ID, allowing optional parameters to customize the response with additional user fields, expansions, and tweet fields. |
|
|
83
|
+
| `users_id_follow` | Follows another user on behalf of the current user using the Twitter API, returning a status message indicating whether the action was successful. |
|
|
84
|
+
| `users_id_liked_tweets` | Retrieves a list of tweets liked by the specified user, supporting pagination and optional expansions and fields for tweets, users, media, polls, and places. |
|
|
85
|
+
| `users_id_like` | Creates a new like for a user's content using the provided user ID and returns a status message. |
|
|
86
|
+
| `users_id_unlike` | Deletes a user's like on a specific tweet using the provided user ID and tweet ID, requiring OAuth2UserToken with "like.write," "tweet.read," and "users.read" permissions. |
|
|
87
|
+
| `get_user_list_memberships` | Retrieves a list of memberships for a specified user using their ID, allowing for optional filtering by maximum results and pagination, and returns the membership details. |
|
|
88
|
+
| `users_id_mentions` | Retrieves the timeline of tweets that mention the user associated with the provided ID, allowing for customization with parameters such as since and until IDs, pagination tokens, and various field expansions. |
|
|
89
|
+
| `users_id_muting` | Retrieves a list of users muted by the specified user using the Twitter API with optional filtering by max results, pagination token, user fields, user expansions, tweet fields, and returns the response upon authorization with the required "mute.read," "tweet.read," and "users.read" scopes. |
|
|
90
|
+
| `users_id_mute` | Mutes a user identified by their ID using the API, requiring a POST request with appropriate OAuth2 credentials. |
|
|
91
|
+
| `list_user_owned_lists` | Retrieves a list of Twitter Lists owned by the specified user, supporting optional pagination and field expansions. |
|
|
92
|
+
| `list_user_pinned_lists` | Retrieves the pinned Lists of a specified user by their user ID, returning detailed information about each pinned List. |
|
|
93
|
+
| `list_user_pin` | Creates a pinned list for a user identified by {id} using JSON data and OAuth2UserToken or UserToken authentication. |
|
|
94
|
+
| `list_user_unpin` | Deletes a specified pinned list from a user's account by user ID and list ID. |
|
|
95
|
+
| `users_id_retweets` | Retweets a post using the X API on behalf of a specified user, requiring authentication with OAuth2UserToken and appropriate permissions. |
|
|
96
|
+
| `users_id_unretweets` | Undoes a retweet of a specified tweet by a user using the Twitter API v2, requiring OAuth authentication and user permissions. |
|
|
97
|
+
| `users_id_timeline` | Retrieves a user's reverse chronological timeline, returning tweets in the order they were posted, with optional filtering by time range, tweet IDs, and additional metadata fields. |
|
|
98
|
+
| `users_id_tweets` | Retrieves a list of tweets for a user with the specified ID, allowing optional filtering by tweet ID range, result count, pagination token, excluded fields, and time range, using the "GET" method. |
|
|
99
|
+
| `users_id_unfollow` | Unfollows a target user by deleting the follow relationship between the source user and the target user using the "DELETE" method. |
|
|
100
|
+
| `users_id_unmute` | Unmutes a target user using the "DELETE" method on the "/2/users/{source_user_id}/muting/{target_user_id}" path, reversing the mute action applied by the source user to the target user. |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .app import TwitterApp
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class APISegmentBase:
|
|
5
|
+
def __init__(self, main_app_client: Any):
|
|
6
|
+
self.main_app_client = main_app_client
|
|
7
|
+
|
|
8
|
+
def _get(self, url: str, params: dict = None, **kwargs):
|
|
9
|
+
return self.main_app_client._get(url, params=params, **kwargs)
|
|
10
|
+
|
|
11
|
+
def _post(
|
|
12
|
+
self,
|
|
13
|
+
url: str,
|
|
14
|
+
data: Any = None,
|
|
15
|
+
files: Any = None,
|
|
16
|
+
params: dict = None,
|
|
17
|
+
content_type: str = None,
|
|
18
|
+
**kwargs,
|
|
19
|
+
):
|
|
20
|
+
return self.main_app_client._post(
|
|
21
|
+
url,
|
|
22
|
+
data=data,
|
|
23
|
+
files=files,
|
|
24
|
+
params=params,
|
|
25
|
+
content_type=content_type,
|
|
26
|
+
**kwargs,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
def _put(
|
|
30
|
+
self,
|
|
31
|
+
url: str,
|
|
32
|
+
data: Any = None,
|
|
33
|
+
files: Any = None,
|
|
34
|
+
params: dict = None,
|
|
35
|
+
content_type: str = None,
|
|
36
|
+
**kwargs,
|
|
37
|
+
):
|
|
38
|
+
return self.main_app_client._put(
|
|
39
|
+
url,
|
|
40
|
+
data=data,
|
|
41
|
+
files=files,
|
|
42
|
+
params=params,
|
|
43
|
+
content_type=content_type,
|
|
44
|
+
**kwargs,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def _patch(self, url: str, data: Any = None, params: dict = None, **kwargs):
|
|
48
|
+
return self.main_app_client._patch(url, data=data, params=params, **kwargs)
|
|
49
|
+
|
|
50
|
+
def _delete(self, url: str, params: dict = None, **kwargs):
|
|
51
|
+
return self.main_app_client._delete(url, params=params, **kwargs)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from .api_segment_base import APISegmentBase
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ComplianceApi(APISegmentBase):
|
|
7
|
+
def __init__(self, main_app_client: Any):
|
|
8
|
+
super().__init__(main_app_client)
|
|
9
|
+
|
|
10
|
+
def list_batch_compliance_jobs(
|
|
11
|
+
self, type, status=None, compliance_job_fields=None
|
|
12
|
+
) -> dict[str, Any]:
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
Retrieves a list of compliance jobs based on the specified job type, with optional filtering by status.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
type (string): The type parameter specifies the compliance job type and must be either "tweets" or "users".
|
|
19
|
+
status (string): Filters compliance jobs by their current status, which can be one of: created, in_progress, failed, or complete.
|
|
20
|
+
compliance_job_fields (array): A comma separated list of ComplianceJob fields to display. Example: "['created_at', 'download_expires_at', 'download_url', 'id', 'name', 'resumable', 'status', 'type', 'upload_expires_at', 'upload_url']".
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
dict[str, Any]: The request has succeeded.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
27
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
28
|
+
|
|
29
|
+
Tags:
|
|
30
|
+
Compliance
|
|
31
|
+
"""
|
|
32
|
+
url = f"{self.main_app_client.base_url}/2/compliance/jobs"
|
|
33
|
+
query_params = {
|
|
34
|
+
k: v
|
|
35
|
+
for k, v in [
|
|
36
|
+
("type", type),
|
|
37
|
+
("status", status),
|
|
38
|
+
("compliance_job.fields", compliance_job_fields),
|
|
39
|
+
]
|
|
40
|
+
if v is not None
|
|
41
|
+
}
|
|
42
|
+
response = self._get(url, params=query_params)
|
|
43
|
+
response.raise_for_status()
|
|
44
|
+
return response.json()
|
|
45
|
+
|
|
46
|
+
def create_batch_compliance_job(
|
|
47
|
+
self, type, name=None, resumable=None
|
|
48
|
+
) -> dict[str, Any]:
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
Creates a new compliance job using JSON data in the request body and authenticates the request using a Bearer token.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
type (string): Type of compliance job to list.
|
|
55
|
+
name (string): User-provided name for a compliance job. Example: 'my-job'.
|
|
56
|
+
resumable (boolean): If true, this endpoint will return a pre-signed URL with resumable uploads enabled.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
dict[str, Any]: The request has succeeded.
|
|
60
|
+
|
|
61
|
+
Raises:
|
|
62
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
63
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
64
|
+
|
|
65
|
+
Tags:
|
|
66
|
+
Compliance
|
|
67
|
+
"""
|
|
68
|
+
request_body_data = None
|
|
69
|
+
request_body_data = {"name": name, "resumable": resumable, "type": type}
|
|
70
|
+
request_body_data = {
|
|
71
|
+
k: v for k, v in request_body_data.items() if v is not None
|
|
72
|
+
}
|
|
73
|
+
url = f"{self.main_app_client.base_url}/2/compliance/jobs"
|
|
74
|
+
query_params = {}
|
|
75
|
+
response = self._post(
|
|
76
|
+
url,
|
|
77
|
+
data=request_body_data,
|
|
78
|
+
params=query_params,
|
|
79
|
+
content_type="application/json",
|
|
80
|
+
)
|
|
81
|
+
response.raise_for_status()
|
|
82
|
+
return response.json()
|
|
83
|
+
|
|
84
|
+
def get_batch_compliance_job(
|
|
85
|
+
self, id, compliance_job_fields=None
|
|
86
|
+
) -> dict[str, Any]:
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
Retrieves information about a compliance job by its ID using the BearerToken for authentication.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
id (string): id
|
|
93
|
+
compliance_job_fields (array): A comma separated list of ComplianceJob fields to display. Example: "['created_at', 'download_expires_at', 'download_url', 'id', 'name', 'resumable', 'status', 'type', 'upload_expires_at', 'upload_url']".
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
dict[str, Any]: The request has succeeded.
|
|
97
|
+
|
|
98
|
+
Raises:
|
|
99
|
+
HTTPError: Raised when the API request fails (e.g., non-2XX status code).
|
|
100
|
+
JSONDecodeError: Raised if the response body cannot be parsed as JSON.
|
|
101
|
+
|
|
102
|
+
Tags:
|
|
103
|
+
Compliance
|
|
104
|
+
"""
|
|
105
|
+
if id is None:
|
|
106
|
+
raise ValueError("Missing required parameter 'id'.")
|
|
107
|
+
url = f"{self.main_app_client.base_url}/2/compliance/jobs/{id}"
|
|
108
|
+
query_params = {
|
|
109
|
+
k: v
|
|
110
|
+
for k, v in [("compliance_job.fields", compliance_job_fields)]
|
|
111
|
+
if v is not None
|
|
112
|
+
}
|
|
113
|
+
response = self._get(url, params=query_params)
|
|
114
|
+
response.raise_for_status()
|
|
115
|
+
return response.json()
|
|
116
|
+
|
|
117
|
+
def list_tools(self):
|
|
118
|
+
return [
|
|
119
|
+
self.list_batch_compliance_jobs,
|
|
120
|
+
self.create_batch_compliance_job,
|
|
121
|
+
self.get_batch_compliance_job,
|
|
122
|
+
]
|