docs: add Xquik read context example#321
Conversation
Reviewer's GuideAdds a new Unla configuration for read-only Xquik-backed X/Twitter MCP tools and links it from the main README quick-start flow, providing search, tweet lookup, user lookup, and reply-reading capabilities with credentials loaded from the runtime environment and write-like actions explicitly excluded. Sequence diagram for xquik_search_tweets tool invocationsequenceDiagram
actor User
participant MCPClient
participant UnlaServer as Unla_xquik-read-context
participant XquikAPI
User ->> MCPClient: invoke tool xquik_search_tweets(query, limit)
MCPClient ->> UnlaServer: xquik_search_tweets with args
UnlaServer ->> UnlaServer: load env XQUIK_API_KEY
UnlaServer ->> XquikAPI: GET /api/v1/x/tweets/search?q=query&limit=limit
XquikAPI -->> UnlaServer: tweets, total
UnlaServer -->> MCPClient: responseBody tweets, total
MCPClient -->> User: display search results
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues, and left some high level feedback:
- In
xquik_search_tweets, thelimitarg is typed asnumberbut the default is the string "20"; consider using an unquoted numeric default to avoid type/coercion surprises. - The
xquik_get_tweet_repliesendpoint always appendscursor={{.Args.cursor}}, which will sendcursor=on first calls; if the template engine allows it, consider conditionally including the cursor parameter only when non-empty to avoid ambiguous query strings.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `xquik_search_tweets`, the `limit` arg is typed as `number` but the default is the string "20"; consider using an unquoted numeric default to avoid type/coercion surprises.
- The `xquik_get_tweet_replies` endpoint always appends `cursor={{.Args.cursor}}`, which will send `cursor=` on first calls; if the template engine allows it, consider conditionally including the cursor parameter only when non-empty to avoid ambiguous query strings.
## Individual Comments
### Comment 1
<location path="configs/proxy-xquik-read-context.yaml" line_range="14-23" />
<code_context>
+ - server: "xquik-read-context"
+ prefix: "/gateway/xquik"
+ cors:
+ allowOrigins:
+ - "*"
+ allowMethods:
+ - "GET"
+ - "OPTIONS"
+ allowHeaders:
+ - "Content-Type"
+ - "Authorization"
+ - "Mcp-Session-Id"
+ - "mcp-protocol-version"
+ exposeHeaders:
+ - "Mcp-Session-Id"
+ - "mcp-protocol-version"
+ allowCredentials: true
+
+servers:
</code_context>
<issue_to_address>
**issue (bug_risk):** CORS configuration uses `allowOrigins: "*"` with `allowCredentials: true`, which is invalid per the CORS spec and may be ignored by browsers.
With `allowCredentials: true`, the CORS response must use a specific origin value, not `*`. Browsers will reject this combination. Please either (a) restrict `allowOrigins` to the expected origins, or (b) set `allowCredentials: false` if you truly need `*` and can do without credentials.
</issue_to_address>
### Comment 2
<location path="configs/proxy-xquik-read-context.yaml" line_range="41-46" />
<code_context>
+ - name: "xquik_search_tweets"
+ description: "Search public X/Twitter posts for source context before drafting or analysis"
+ method: "GET"
+ endpoint: "https://xquik.com/api/v1/x/tweets/search?q={{.Args.query}}&limit={{.Args.limit}}"
+ headers:
+ X-API-Key: "{{.Config.XAPIKey}}"
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Query parameters are interpolated without URL encoding, which can break the request for complex queries.
`.Args.query` may include spaces or characters like `#` and `@` that must be URL-encoded (e.g., `q=from:foo bar` will produce an invalid URL). Use a URL-encoding helper in the template (e.g., `{{ urlquery .Args.query }}` or equivalent) for this and any other query parameters to prevent malformed requests.
```suggestion
- name: "xquik_search_tweets"
description: "Search public X/Twitter posts for source context before drafting or analysis"
method: "GET"
endpoint: "https://xquik.com/api/v1/x/tweets/search?q={{ urlquery .Args.query }}&limit={{ urlquery .Args.limit }}"
headers:
X-API-Key: "{{.Config.XAPIKey}}"
```
</issue_to_address>
### Comment 3
<location path="configs/proxy-xquik-read-context.yaml" line_range="54-59" />
<code_context>
+ type: "string"
+ description: "X search syntax, keyword, account, or URL-derived query"
+ default: ""
+ - name: "limit"
+ position: "query"
+ required: false
+ type: "number"
+ description: "Maximum posts to return"
+ default: "20"
+ responseBody: |-
+ {
</code_context>
<issue_to_address>
**issue (bug_risk):** The `limit` argument is typed as `number` but the default value is a string.
Given `type: "number"` for `limit`, using a string default (`"20"`) may cause parsing or validation issues. Please change the default to a numeric literal, e.g. `default: 20`, to match the declared type.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
7705032 to
65a57cc
Compare
|
Addressed the Sourcery review in Changes:
Validation rerun:
|
|
Published The original Sourcery findings remain resolved. This pass also fixed current integration drift found during an end-to-end configuration audit:
The independent Unla fix remains intact: single-config validation rejects normalized router-prefix collisions such as Validation passed: Xquik is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp. |
3ab62dd to
b2cd0d1
Compare
Summary
Review Repairs
GET,POST, andDELETEmethods.qparameter.default: "20"becauseArgConfig.Defaultis a Go string.Independent Repository Fix
ValidateMCPConfigpreviously accepted/apiand/api/together. Both normalize to the same route, so hot updates could create ambiguous routing. Validation now rejects this collision. Global validation also avoids reporting the same within-config collision twice.Validation
make testgo test ./internal/common/config ./internal/core/... ./internal/template/...go vet ./...go build ./cmd/apiserver ./cmd/mcp-gateway ./cmd/mock-servergit diff --checkThe branch contains exactly 1 SSH-signed, GitHub-verified commit.
Xquik is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.