<!-- CURSOR_SUMMARY --> > [!NOTE] > **Medium Risk** > Touches multiple toolkits’ runtime entrypoints and context/error/auth plumbing, so breakage risk is mainly around invocation/packaging and tool execution wiring rather than business logic. > > **Overview** > Migrates the BrightData, ClickHouse, LinkedIn, Math, MongoDB, Postgres, and Zendesk OSS toolkits from `arcade-tdk` to `arcade-mcp-server` APIs by updating tool decorators, `Context` types, auth classes, and exception imports. > > Adds per-toolkit `__main__.py` files that construct an `MCPApp`, register module tools, and run via configurable transport/host/port; corresponding `pyproject.toml` updates bump versions, drop `arcade-tdk`/`arcade-serve` deps, and add `project.scripts` console entrypoints. > > Updates tests and eval suites to use `arcade_mcp_server.Context` (mocked) and switches eval `ToolCatalog` imports to `arcade_core`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9b3e31acb4b35e1d72efd47e2d279c5b19e3ecb0. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
from typing import Annotated
|
|
|
|
from arcade_mcp_server import Context, tool
|
|
from arcade_mcp_server.auth import LinkedIn
|
|
from arcade_mcp_server.exceptions import ToolExecutionError
|
|
from arcade_mcp_server.metadata import (
|
|
Behavior,
|
|
Classification,
|
|
Operation,
|
|
ServiceDomain,
|
|
ToolMetadata,
|
|
)
|
|
|
|
from arcade_linkedin.tools.utils import _handle_linkedin_api_error, _send_linkedin_request
|
|
|
|
|
|
@tool(
|
|
requires_auth=LinkedIn(
|
|
scopes=["w_member_social"],
|
|
),
|
|
metadata=ToolMetadata(
|
|
classification=Classification(
|
|
service_domains=[ServiceDomain.SOCIAL_MEDIA],
|
|
),
|
|
behavior=Behavior(
|
|
operations=[Operation.CREATE],
|
|
read_only=False,
|
|
destructive=False,
|
|
idempotent=False,
|
|
open_world=True,
|
|
),
|
|
),
|
|
)
|
|
async def create_text_post(
|
|
context: Context,
|
|
text: Annotated[str, "The text content of the post"],
|
|
) -> Annotated[str, "URL of the shared post"]:
|
|
"""Share a new text post to LinkedIn."""
|
|
endpoint = "/ugcPosts"
|
|
|
|
# The LinkedIn user ID is required to create a post, even though we're using
|
|
# the user's access token.
|
|
# Arcade Engine gets the current user's info from LinkedIn and automatically
|
|
# populates context.authorization.user_info.
|
|
# LinkedIn calls the user ID "sub" in their user_info data payload. See:
|
|
# https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2#api-request-to-retreive-member-details
|
|
user_id = context.authorization.user_info.get("sub") if context.authorization else None
|
|
|
|
if not user_id:
|
|
raise ToolExecutionError(
|
|
"User ID not found.",
|
|
developer_message="User ID not found in `context.authorization.user_info.sub`",
|
|
)
|
|
|
|
author_id = f"urn:li:person:{user_id}"
|
|
payload = {
|
|
"author": author_id,
|
|
"lifecycleState": "PUBLISHED",
|
|
"specificContent": {
|
|
"com.linkedin.ugc.ShareContent": {
|
|
"shareCommentary": {"text": text},
|
|
"shareMediaCategory": "NONE",
|
|
}
|
|
},
|
|
"visibility": {"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"},
|
|
}
|
|
|
|
response = await _send_linkedin_request(context, "POST", endpoint, json_data=payload)
|
|
|
|
if response.status_code >= 200 and response.status_code < 300:
|
|
share_id = response.json().get("id")
|
|
return f"https://www.linkedin.com/feed/update/{share_id}/"
|
|
|
|
_handle_linkedin_api_error(response)
|
|
|
|
return ""
|