Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Configuration

- `HYPERSPELL_TOKEN` should be a valid user or app token (refer to the [Hyperspell docs](https://docs.hyperspell.com/) for how to obtain a user token).
- Some MCP clients don't support resources well (looking at you, Claude Desktop), so we can expose them as tools instead. Set `HYPERSPELL_USE_RESOURCES` to `false` (default) to expose everything as tools, `true` to expose retrieveing single documents or listing collections as resources instead, or `both` if you want it all.
- Some MCP clients don't support resources well (looking at you, Claude Desktop), so we can expose them as tools instead. Set `HYPERSPELL_USE_RESOURCES` to `false` (default) to expose everything as tools, `true` to expose retrieving single documents or listing collections as resources instead, or `both` if you want it all.
- Optionally, set `HYPERSPELL_COLLECTION` to the name of the collection you want to query and add data to. If not set, it will use the user's default collection instead.


Expand All @@ -26,7 +26,7 @@ Note that Claude needs the absolute path to `uv`, which can be found with `which
],
"env": {
"HYPERSPELL_TOKEN": "<app or user token>",
"USE_RESOURCES": "false"
"HYPERSPELL_USE_RESOURCES": "false"
}
}
}
Expand All @@ -46,4 +46,4 @@ Then run this to start the inspector:

```
uv run mcp dev src/hyperspell_mcp/server.py
```
```
14 changes: 7 additions & 7 deletions src/hyperspell_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def from_env(cls, env_file: str = ".env") -> "ServerConfig":
# Expose resources or tools?
# Some MCP clients don't support resources well (looking at you, Claude Desktop),
# so we can expose them as tools instead.
tools_or_resources = os.getenv("HYPERSPELL_USE_RESOURCES", "true").lower()
tools_or_resources = os.getenv("HYPERSPELL_USE_RESOURCES", "false").lower()
use_resources = tools_or_resources in ("true", "1", "both")
use_tools = tools_or_resources in ("false", "0", "both")

Expand Down Expand Up @@ -96,21 +96,21 @@ async def log(
mcp = HyperspellMCPServer(config=ServerConfig.from_env())


@mcp.tool_or_resource("collection://", name="List Collections")
@mcp.tool_or_resource("collection://", name="list_collections")
def list_collections() -> list[Collection]:
"""Get a list of all collections on Hyperspell"""
r = mcp.api.collections.list()
return Collection.from_pydantic(r.items)


@mcp.tool_or_resource("collection://{collection_name}", name="Get Collection")
@mcp.tool_or_resource("collection://{collection_name}", name="get_collection")
def get_documents(collection_name: str) -> list[Document]:
"""Get a list of all documents in a collection"""
r = mcp.api.documents.list(collection=collection_name)
return Document.from_pydantic(r.items)


@mcp.tool_or_resource("document://{document_id}", name="Get Document")
@mcp.tool_or_resource("document://{document_id}", name="get_document")
def get_document(document_id: int) -> Document | Error:
"""Get a document from a collection"""
# try:
Expand All @@ -121,7 +121,7 @@ def get_document(document_id: int) -> Document | Error:


@mcp.tool(
name="Search Hyperspell", description="Search Hyperspell for documents and data."
name="search_hyperspell", description="Search Hyperspell for documents and data."
)
def query(query: str) -> list[Document]:
"""Search Hyperspell for documents and data."""
Expand All @@ -130,7 +130,7 @@ def query(query: str) -> list[Document]:


@mcp.tool(
name="Add File", description="Add a file or website from a URL to Hyperspell."
name="add_file", description="Add a file or website from a URL to Hyperspell."
)
def add_file(url: str) -> DocumentStatus:
"""Add a file or URL to Hyperspell."""
Expand All @@ -139,7 +139,7 @@ def add_file(url: str) -> DocumentStatus:


@mcp.tool(
name="Add Memory",
name="add_memory",
description="Add a plain text document or memory to Hyperspell.",
)
def add_memory(text: str, title: str | None = None) -> DocumentStatus:
Expand Down