Repository navigation
feat(mcp): add optional SpecStream web search tool - #2477
Open
Specstreamai wants to merge 1 commit into
Open
Specstreamai wants to merge 1 commit into
Specstreamai wants to merge 1 commit into
Conversation
Saving a key under Advanced > SpecStream registers self.specstream.web_search, and clearing it removes the tool. The tool sends one fast search for three results to SpecStream's /v1/web-search and returns the same numbered title, URL and snippet text as the other search tools.
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.
This adds SpecStream as a third optional search tool,
self.specstream.web_search, built the same way as the Firecrawl tool from #2468. Saving a key under Advanced → SpecStream on the provisioning page registers it, and clearing the key removes it. Devices without a SpecStream key see no change, and the Tavily and Firecrawl tools are untouched.The tool sends one
POST https://api.specstream.ai/v1/web-searchwith{"q": ..., "num": 3, "speed": "fast"}and a Bearer key. Fast mode returns the engines' results with their snippets in about a second, so it stays well inside the 8 second timeout. The reply goes throughReadJsonClippedunder the same 16 KB ceiling, anddata.sourcesis formatted by the sharedFormatSearchResultItems, so the output is the same numbered title, URL and snippet text as the other tools.Changes
main/mcp_tools.cc:self.specstream.web_search, registered at boot or when a key is saved (NVS keyspecstream_key, 14 characters). It reusesLoadApiKey,StoreApiKeyandPostSearch.main/mcp_tools.h:HasSpecStreamApiKey,SaveSpecStreamApiKeyand the key length limit.main/web_search_format.h:FormatSpecStreamSearchResults, which readsdata.sourceswithsnippetas the text field.main/boards/common/portal_settings.cc: a SpecStream section with an API key field and zh-CN/zh-TW strings, saved throughSaveApiKey.docs/mcp-usage.md: the tool row and where to set the key.scripts/tests/: registration when a key is saved, cleared or present at boot (the HTTP stub checks the URL, the Bearer header,qandspeedin the body, and that the key never appears in the body), and SpecStream formatting with a parse error, an empty list and a snippet cut on a UTF-8 boundary.How I tested it
python3 -m unittest scripts/tests/test_mcp_server.py scripts/tests/test_web_search_format.py: 37 tests pass, 3 of them new.python3 -m unittest discover -s scripts/tests: everything else passes; the only errors are the 6 intest_ci_selection.py, which callpythonand my host only haspython3.clang-format19 with the repo's.clang-formatgives no changes on the added lines.To try it: flash, open Advanced → SpecStream, paste a key from specstream.ai, save, and ask the device something current. New accounts get $2 of credit with no card, and a fast search is $1 per 1,000.
Disclosure: I work on SpecStream.