feat(mcp): add MCP tool surface for the full X client API#6
Merged
Conversation
Adds a new ./mcp subpackage built on github.com/teslashibe/mcptool that
exposes every exported *x.Client method as an MCP tool with a typed input
struct. Each tool's JSON input schema is reflected from struct tags so
there's no hand-maintained schema and no drift.
A coverage test (TestEveryClientMethodIsWrappedOrExcluded) iterates the
exported method set on *x.Client and fails if a new method is added that
is neither wrapped nor explicitly listed in mcp.Excluded with a reason —
keeping the MCP surface in lockstep with the package API is enforced by
CI rather than convention.
Tools (37):
reads: x_get_profile, x_get_profile_by_id, x_me,
x_get_followers, x_get_following,
x_get_tweet, x_get_tweet_detail, x_get_user_tweets,
x_home_timeline, x_home_latest_timeline,
x_search_tweets, x_search_users, x_advanced_search_tweets,
x_get_conversations, x_get_conversation,
x_get_list, x_get_list_timeline, x_get_list_members,
x_scrape_timeline_trends
writes: x_create_tweet, x_reply, x_quote_tweet, x_delete_tweet,
x_like, x_unlike, x_retweet, x_unretweet,
x_bookmark, x_unbookmark,
x_follow, x_unfollow, x_mute, x_unmute, x_block, x_unblock,
x_send_dm, x_send_new_dm
Excluded (13):
internal/lifecycle:
RateLimit — observability surfaced via host MCP middleware
TransactionInitErr — bootstrap state reported at construction
RefreshQueryIDs — internal session-bootstrap helper
convenience wrappers around the *Page variant exposed as a single
cursor-aware tool:
HomeTimeline, HomeLatestTimeline, UserTweets, SearchTweets,
SearchUsers, AdvancedSearchTweets, GetFollowers, GetFollowing,
GetListTimeline, GetListMembers
Coverage: 37 wrapped, 13 excluded, 0 missing, 0 unknown exclusions.
Adds .github/workflows/mcp-ci.yml gating PRs on `go mod tidy` cleanliness,
`go vet`, `go build`, and `go test -race ./mcp/...`. Updates README with
an "MCP support" section.
Refs: teslashibe/agent-setup#6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
./mcpsubpackage built ongithub.com/teslashibe/mcptoolv0.1.0that exposes every exported*x.Clientmethod as an MCP tool with a typed input struct. Each tool's JSON input schema is reflected from struct tags, so there is no hand-maintained schema and no drift between this package's API and what an agent sees.The structure mirrors
linkedin-go/mcp(just merged via teslashibe/linkedin-go#9): oneProvider, one tool-group file per logical area, one sharedExcludedmap of intentional non-exposures with reasons.Tools (37)
Reads (19)
x_get_profile,x_get_profile_by_id,x_mex_get_followers,x_get_followingx_get_tweet,x_get_tweet_detail,x_get_user_tweetsx_home_timeline,x_home_latest_timelinex_search_tweets,x_search_users,x_advanced_search_tweetsx_get_conversations,x_get_conversationx_get_list,x_get_list_timeline,x_get_list_membersx_scrape_timeline_trendsWrites (18)
x_create_tweet,x_reply,x_quote_tweet,x_delete_tweetx_like,x_unlike,x_retweet,x_unretweet,x_bookmark,x_unbookmarkx_follow,x_unfollow,x_mute,x_unmute,x_block,x_unblockx_send_dm,x_send_new_dmAll tools use snake_case
x_<verb>_<noun>names and have descriptions ≤ 120 chars (enforced byTestToolsValidate). List-returning tools usemcptool.PageOfso the host's response middleware can uniformly cap and surfacenext_cursor. Write tools return{ "ok": true, ...key fields... }on success.Excluded (13)
Internal / lifecycle helpers — surfaced via the host application's middleware, not as agent-callable tools:
RateLimitTransactionInitErrRefreshQueryIDsConvenience wrappers around the corresponding
*Pagevariant — exposed as a single cursor-aware tool to keep the surface compact while retaining pagination:HomeTimeline,HomeLatestTimeline,UserTweets,SearchTweets,SearchUsers,AdvancedSearchTweets,GetFollowers,GetFollowing,GetListTimeline,GetListMembers.Drift prevention
mcp/mcp_test.gorunsmcptool.Coverage(reflect.TypeOf(&x.Client{}), Provider{}.Tools(), Excluded)and fails when:*x.Clientis neither wrapped by a tool nor listed inExcluded(Missing)Excludedreferences a method that no longer exists (UnknownExclusions)Current report:
37 wrapped, 13 excluded, 0 missing, 0 unknown exclusions.Tools also pass
mcptool.ValidateTools(canonical name regex, ≤ 120-char description, non-nilInvokeandInputSchema, no duplicates) and thex_prefix check.CI
Adds
.github/workflows/mcp-ci.yml. On any push tomainor PR touchingmcp/**,**/*.go,go.mod,go.sum, or the workflow itself:go mod tidy— must produce no diffgo vet ./...go build ./...go test -race -count=1 ./mcp/...Guardrails respected
go.modunchanged (1.25.5)github.com/teslashibe/mcptool v0.1.0(and its transitive deps)Test plan
go vet ./...cleango build ./...cleango test -race -count=1 ./mcp/...green locallyx_prefixRefs: teslashibe/agent-setup#6