What is the Model Context Protocol?

In the 1980s, the personal computing revolution put a computer in every living room. Much of it was fueled by the idea of a “Graphical User Interface” (GUI), standardizing how humans and programs interacted. Twenty years later, cloud computing put software on the internet. Programs started being developed around APIs (Application Programming Interfaces) instead, standardizing how programs interacted with other and programs. We are on the precipise of agentic computing — programs that can autonomously decide what to do next, solve ambiguous problems, and decide what data and resources they need to accomplish their goals. But we’re still missing a standard way for agents to interact with the rest of the world — an agentic interface layer. The Model Context Protocol (MCP) is a big step in this direction. It’s an open standard developed by Anthropic to help AI models, agents, and systems connect with external data sources and tools.

How does MCP work?

The MCP distinguishes between Clients and Servers. Clients are AI applications, like Claude Desktop, Cursor, and Windsurf. Servers expose data and tools to the client, and are usually created by the company or developers that host the data, but there is a rich ecosystem of third-party servers too. In Hyperspell’s case, we’re providing an MCP server that lets you query and add data to your Hyperspell app.

Local vs Remote Servers

There are two flavors of MCP servers:
  • Local servers run on your own machine, and are great for uses cases involving your local files, or even controlling your own hardware.
  • Remote servers run in the cloud, and make it easy to connect clients.

Tools, Prompts, and Resources

MCP servers provide clients with tools, resources, prompts, completions, and more. You can read more about them on the Model Context Protocol website, but the Hyperspell MCP server is focused on providing tools and resources:
  • Tools are actions that can be taken by the client. In our case, we’re providing the tools to query Hyperspell for data, and to add data to Hyperspell either by providing text that Hyperspell should remember, or the URL to a file or web page.
  • Resources are data sources that can be queried by the client. For example, a resource could be a file in your local filesystem, or a record in a database. With the Hyperspell MCP server, you retrieve your memories as resources.
Some MCP Clients (looking at you, Claude Desktop) have only poor support for using resources, so you can configure the Hyperspell MCP server to expose collections and documents as tools rather than as resources so Claude can dynamically accesst them when needed.

Usage

Direct Invocation

You can run the Hyperspell MCP Server directly via npx:
export HYPERSPELL_TOKEN="My API Key"
export HYPERSPELL_USER_ID="My User ID"
npx -y hyperspell-mcp@latest

Via MCP Client (ie. Claude Desktop)

There is a partial list of existing clients at modelcontextprotocol.io. Please consult the documentation for your client to install the Hyperspell MCP Server. For clients with a configuration JSON such as Claude Desktop, it might look something like this:
This file is located in ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, and %APPDATA%\Claude\claude_desktop_config.json on Windows.
{
  "mcpServers": {
    "hyperspell": {
      "command": "npx",
      "args": ["-y", "hyperspell-mcp", "--client=claude", "--tools=all"],
      "env": {
        "HYPERSPELL_TOKEN": "My API Key",
        "HYPERSPELL_USER_ID": "My User ID"
      }
    }
  }
}
Replace the HYPERSPELL_TOKEN with your Hyperspell app token and the HYPERSPELL_USER_ID with the ID of the user you want to use the MCP Server for.

Exposing endpoints to your MCP Client

There are two ways to expose endpoints as tools in the MCP server:
  1. Exposing one tool per endpoint, and filtering as necessary
  2. Exposing a set of tools to dynamically discover and invoke endpoints from the API

Filtering endpoints and tools

You can run the package on the command line to discover and filter the set of tools that are exposed by the MCP Server. This can be helpful for large APIs where including all endpoints at once is too much for your AI’s context window. You can filter by multiple aspects:
  • --tool includes a specific tool by name
  • --resource includes all tools under a specific resource, and can have wildcards, e.g. my.resource*
  • --operation includes just read (get/list) or just write operations

Dynamic tools

If you specify --tools=dynamic to the MCP server, instead of exposing one tool per endpoint in the API, it will expose the following tools:
  1. list_api_endpoints - Discovers available endpoints, with optional filtering by search query
  2. get_api_endpoint_schema - Gets detailed schema information for a specific endpoint
  3. invoke_api_endpoint - Executes any endpoint with the appropriate parameters
This allows you to have the full set of API endpoints available to your MCP Client, while not requiring that all of their schemas be loaded into context at once. Instead, the LLM will automatically use these tools together to search for, look up, and invoke endpoints dynamically. However, due to the indirect nature of the schemas, it can struggle to provide the correct properties a bit more than when tools are imported explicitly. Therefore, you can opt-in to explicit tools, the dynamic tools, or both. See more information with --help. All of these command-line options can be repeated, combined together, and have corresponding exclusion versions (e.g. --no-tool). Use --list to see the list of available tools, or see below.

Specifying the MCP Client

Different clients have varying abilities to handle arbitrary tools and schemas. You can specify the client you are using with the --client argument, and the MCP server will automatically serve tools and schemas that are more compatible with that client.
  • --client=<type>: Set all capabilities based on a known MCP client
    • Valid values: openai-agents, claude, claude-code, cursor
    • Example: --client=cursor
Additionally, if you have a client not on the above list, or the client has gotten better over time, you can manually enable or disable certain capabilities:
  • --capability=<name>: Specify individual client capabilities
    • Available capabilities:
      • top-level-unions: Enable support for top-level unions in tool schemas
      • valid-json: Enable JSON string parsing for arguments
      • refs: Enable support for $ref pointers in schemas
      • unions: Enable support for union types (anyOf) in schemas
      • formats: Enable support for format validations in schemas (e.g. date-time, email)
      • tool-name-length=N: Set maximum tool name length to N characters
    • Example: --capability=top-level-unions --capability=tool-name-length=40
    • Example: --capability=top-level-unions,tool-name-length=40

Importing the tools and server individually

// Import the server, generated endpoints, or the init function
import { server, endpoints, init } from "hyperspell-mcp/server";

// import a specific tool
import addDocuments from "hyperspell-mcp/tools/documents/add-documents";

// initialize the server and all endpoints
init({ server, endpoints });

// manually start server
const transport = new StdioServerTransport();
await server.connect(transport);

// or initialize your own server with specific tools
const myServer = new McpServer(...);

// define your own endpoint
const myCustomEndpoint = {
  tool: {
    name: 'my_custom_tool',
    description: 'My custom tool',
    inputSchema: zodToJsonSchema(z.object({ a_property: z.string() })),
  },
  handler: async (client: client, args: any) => {
    return { myResponse: 'Hello world!' };
  })
};

// initialize the server with your custom endpoints
init({ server: myServer, endpoints: [addDocuments, myCustomEndpoint] });

Available Tools

The following tools are available in this MCP server.
  • user_info: Get basic info about the current user, including which integrations are currently enabled and which ones are available.
  • add_document: This tool lets you add text, markdown, or JSON to the Hyperspell index so it can be searched later. It will return the source and resource_id that can be used to later retrieve the processed document.
  • get_document: This tool lets you retrieve a a document that has been previously indexed.
  • upload_file: This tool lets you upload a file to the Hyperspell index. It will return the source and resource_id that can be used to later retrieve the processed document.
  • search: Search all documents indexed by Hyperspell. Set answer to true to directly answer the query, or to false to simply get all documents related to the query.

Source Code

You can explore the source code for the Hyperspell MCP Server on GitHub:

Hyperspell MCP Server

Explore the source code for the Hyperspell MCP Server on GitHub.