search1api 0.1.1 (fatwang2):
- Sign-ins carry utm_source=magpie and API requests send User-Agent search1api-magpie/0.1.1.
- The registered public OAuth client and its loopback port are saved in search1api-oauth-client.json (mode 600) and reused. A busy port, another issuer, or a sign-in that doesn't finish leads to a new registration.
- A send_feedback tool posts to Search1API's own POST /feedback with the caller's credential, on the same request path as the other tools, including the OAuth refresh on 401. Its description lists what is sent (message, intent, category, request_id, model) and says Search1API stores it on agentback.app, linked to the signed-in account. The plugin contacts no other host. A report that can't be sent returns a note and doesn't fail the task.
Run at the reviewed head d48c8c8 (sandbox HOME/TMPDIR, Bun 1.4.2):
- bun test packages/search1api/tests: 23 pass, 0 fail
- bun scripts/check.mjs search1api: ok
- PR CI (test, on-npm): pass
- grep of the package: the only host is api.search1api.com (plus 127.0.0.1 for the callback). No hard-coded keys. agentback.app appears only in the description, the README and a test.
- Drove the built plugin against my own loopback fake API:
- OAuth access revoked (401): POST /feedback with the old bearer, then /token refresh_token, then POST /feedback with the new bearer. Got "Feedback recorded (fb_1)" and auth.set with the new token.
- Bad API key: a 401 gives "not recorded ... (401)" with no refresh, and the error body is not echoed.
- Body is exactly {message, intent, category, request_id, agent:{name:"Magpie", model}}, with UA search1api-magpie/0.1.1.
- Unknown args and a non-string model are refused before any request.
- An unauthenticated probe of the real api.search1api.com: POST /feedback gives 401, and an unknown path gives 404. So the endpoint exists.
- The OAuth client reuse (unchanged since 95f236f) was run by hand in the previous review.
Not tried: a real Search1API account (none available).
203 lines
7.9 KiB
Markdown
203 lines
7.9 KiB
Markdown
# Search1API for Magpie
|
|
|
|
Search1API web search, news, agentic search, page retrieval, sitemap discovery,
|
|
and trending tools in [Magpie](https://usemagpie.ai/), with browser OAuth and
|
|
API key sign-in. The source lives in this community repository and is published as
|
|
`@magpie-community/tools-search1api`. It uses native fetch with no runtime
|
|
dependencies; request bodies and defaults match the original integration.
|
|
|
|
## Install
|
|
|
|
In Magpie, open **Plugins → Add plugin** and enter:
|
|
|
|
```text
|
|
@magpie-community/tools-search1api
|
|
```
|
|
|
|
Or use the terminal:
|
|
|
|
```sh
|
|
magpie plugin add @magpie-community/tools-search1api
|
|
```
|
|
|
|
The package includes its TypeScript source and an `index.mjs` entry. Magpie's
|
|
Bun host loads it directly; installation and community packaging need no build.
|
|
|
|
## Sign in
|
|
|
|
### OAuth (recommended)
|
|
|
|
Choose **Search1API → Sign in to Search1API** in the plugin's sign-in controls,
|
|
or run:
|
|
|
|
```sh
|
|
magpie plugin login search1api oauth
|
|
```
|
|
|
|
Magpie opens your browser. Sign in with your Search1API account and approve
|
|
access, then return to Magpie. The plugin uses a dynamically registered public
|
|
OAuth client, authorization code flow with PKCE S256, and a temporary loopback
|
|
callback. No client secret or Search1API CLI is required.
|
|
|
|
The client is registered once and saved, with its callback port, in
|
|
`search1api-oauth-client.json` next to `plugin-auth.json`; later sign-ins
|
|
reuse it. If that port is busy, or a sign-in with the saved client does not
|
|
finish, the plugin registers a new client. The authorization URL carries
|
|
`utm_source=magpie` and API requests send `User-Agent: search1api-magpie/<version>`,
|
|
so Search1API can tell sign-ups and usage that come from Magpie.
|
|
|
|
The browser must run on the same computer as Magpie. For a remote or container
|
|
installation, use an API key instead. The callback expires after five minutes.
|
|
|
|
Magpie saves access and refresh tokens in `plugin-auth.json` under its config
|
|
directory (`~/.config/magpie`, or `$XDG_CONFIG_HOME/magpie`) with file mode
|
|
`0600`. The plugin reads only its own `search1api` entry and saves refreshed
|
|
tokens through Magpie's `client.auth.set`; it does not maintain a second token
|
|
store. Tool calls refresh expiring tokens and retry once after an OAuth `401`.
|
|
Refreshes are serialized across simultaneous calls and Magpie processes.
|
|
|
|
Search1API appears as a sign-in entry with **no chat models**. It authenticates
|
|
the tools, not a model provider. One Search1API account is active at a time;
|
|
signing in again replaces it.
|
|
|
|
To remove the saved sign-in:
|
|
|
|
```sh
|
|
magpie plugin logout search1api
|
|
```
|
|
|
|
This removes the local credentials. It does not revoke an authorization at the
|
|
authorization server or remove API keys configured separately below.
|
|
|
|
### API key
|
|
|
|
Choose **Search1API API key** in the same sign-in controls, or run:
|
|
|
|
```sh
|
|
magpie plugin login search1api api
|
|
```
|
|
|
|
Magpie prompts privately for the key and saves it in its credential store.
|
|
Get a key at [s1.dev](https://s1.dev/?utm_source=magpie&utm_medium=readme).
|
|
|
|
For automated deployments, the plugin also accepts an `apiKey` plugin option
|
|
in Magpie's options editor, or `SEARCH1API_API_KEY` in the environment of the
|
|
Magpie process. Precedence: plugin option → environment → Magpie sign-in.
|
|
An option or environment key overrides a saved OAuth account. `SEARCH1API_KEY`
|
|
and the CLI's `s1 login` session are not read.
|
|
|
|
`baseUrl` is an optional API base URL for a compatible deployment or local
|
|
testing. It defaults to `https://api.search1api.com`. HTTPS is required, except
|
|
for loopback test servers. OAuth discovery uses that API's protected-resource
|
|
metadata and validates the issuer and endpoints.
|
|
|
|
## Connect your agent
|
|
|
|
In **Settings → Plugins**, copy the plugin tools MCP address, then add it to
|
|
your agent's MCP configuration. The default address is:
|
|
|
|
```text
|
|
http://127.0.0.1:3425/mcp/magpie/tools
|
|
```
|
|
|
|
For Claude Code:
|
|
|
|
```sh
|
|
claude mcp add --transport http magpie-tools \
|
|
http://127.0.0.1:3425/mcp/magpie/tools
|
|
```
|
|
|
|
Other agents use the same Streamable HTTP endpoint. Use the address Magpie
|
|
shows if the port or host differs. Remote calls require a Magpie gateway key;
|
|
this is separate from your Search1API credential.
|
|
|
|
Installing the plugin does not write your agent's MCP configuration or replace
|
|
its built-in search tool. Magpie exposes tools from all enabled tool plugins
|
|
on this endpoint.
|
|
|
|
## Tools
|
|
|
|
Magpie prefixes each tool with the plugin name. Use the names reported by
|
|
your Magpie tools endpoint.
|
|
|
|
- `search`: web search, engine selection, site filters, date range and native
|
|
pagination. Page selection works on engines that support it.
|
|
- `news`: news search with optional article content.
|
|
- `ask`: describe what to find; Search1API chooses engines and a time window
|
|
and returns ranked results. Each completed call costs **5 credits**. It
|
|
returns search results rather than a generated answer.
|
|
- `crawl`: retrieve readable page content.
|
|
- `sitemap`: discover site links.
|
|
- `trending`: GitHub or Hacker News trends.
|
|
- `send_feedback`: report a wrong or empty result, an unresolved error,
|
|
mismatched docs or a missing capability to the Search1API team, through
|
|
Search1API's `POST /feedback` API. It is free and needs a Search1API sign-in or API key. The report (message,
|
|
intent, category, request id and model) goes only to Search1API, which stores
|
|
it in its feedback inbox on [Agentback](https://agentback.app), a
|
|
third-party host, linked to your Search1API account.
|
|
|
|
Search tool parameters follow the existing OpenCode integration. Search and news
|
|
preserve optional `published_date` and per-result `metadata`; Ask preserves
|
|
`intent`, `source`, `relevance`, and `errors`. Attribute Grokipedia results as
|
|
“Powered by xAI”. Results are returned as JSON text.
|
|
|
|
Magpie gives tools a 55-second deadline. Cancellation is forwarded to fetch.
|
|
Automatic request retries are disabled to keep calls within that deadline; OAuth
|
|
authentication is retried once after refreshing. Other upstream errors return
|
|
to the calling agent.
|
|
|
|
## Development
|
|
|
|
From this folder, on Node 24 or later (or Bun for the tests):
|
|
|
|
```sh
|
|
npm install --workspaces=false --ignore-scripts --package-lock=false
|
|
npm run lint
|
|
npm run typecheck
|
|
npm run build
|
|
npm test
|
|
npm pack --dry-run --ignore-scripts
|
|
```
|
|
|
|
The TypeScript build is a local verification artifact in `dist/`; the published
|
|
package contains the reviewed source. `lint` checks the entry syntax and runs
|
|
the strict TypeScript checks (including unused code and switch fallthrough).
|
|
|
|
From the repository root, run the same checks as community CI with a temporary
|
|
home, as documented in `.github/workflows/pr.yml`:
|
|
|
|
```sh
|
|
bun test
|
|
bun scripts/check.mjs
|
|
```
|
|
|
|
The fetch-stub tests replace every fetch with synthetic responses, covering
|
|
all six wire bodies, defaults, validation, safe errors, OAuth discovery,
|
|
refresh/retry limits and cancellation. Local loopback fixtures additionally
|
|
exercise PKCE browser callbacks, key precedence, concurrent refreshes and
|
|
logout without real accounts or paid API calls.
|
|
|
|
An optional integration test uses Magpie's actual Bun plugin host and the same
|
|
local fixture. It is outside the default test filename pattern:
|
|
|
|
```sh
|
|
MAGPIE_HOST_PATH=/path/to/magpie/internal/plugin/host.js \
|
|
MAGPIE_BUN_PATH=/path/to/bun npm run test:magpie
|
|
```
|
|
|
|
The migrated integration was verified against Magpie host revision
|
|
`8ef9fc578ced531b7ca835a3133c37f608a70e6a`. Live-account OAuth consent still
|
|
requires manual verification on the machine running Magpie.
|
|
|
|
## Maintenance and license
|
|
|
|
Migrated from [Search1API for Magpie v0.1.0](https://github.com/superagents-lab/magpie-search1api/tree/v0.1.0),
|
|
commit `89b9cd5fd1c1c105d603768c14404873d697941f`, under MIT. The original
|
|
Search1API copyright and license are retained in `LICENSE`.
|
|
|
|
This replaces the external-package listing proposed in
|
|
[#340](https://github.com/magpie-community/plugins/pull/340). Source changes
|
|
are reviewed here and published by `@magpie-community` through this
|
|
repository's existing publishing workflow; see the root README. This package
|
|
does not publish from the original repository's release workflow.
|