@anyproto/anytype-mcp 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ jobs:
30
30
  - name: Run linter
31
31
  run: npm run lint
32
32
 
33
- type-check:
33
+ typecheck:
34
34
  runs-on: ubuntu-latest
35
35
 
36
36
  steps:
@@ -46,7 +46,7 @@ jobs:
46
46
  run: npm install
47
47
 
48
48
  - name: Run type checks
49
- run: npm run type-check
49
+ run: npm run typecheck
50
50
 
51
51
  build:
52
52
  runs-on: ubuntu-latest
@@ -65,3 +65,21 @@ jobs:
65
65
 
66
66
  - name: Build extension
67
67
  run: npm run build
68
+
69
+ test:
70
+ runs-on: ubuntu-latest
71
+
72
+ steps:
73
+ - name: Checkout code
74
+ uses: actions/checkout@v4
75
+
76
+ - name: Set up Node.js
77
+ uses: actions/setup-node@v4
78
+ with:
79
+ node-version: "22"
80
+
81
+ - name: Install dependencies
82
+ run: npm install
83
+
84
+ - name: Run tests
85
+ run: npm run test
@@ -27,7 +27,13 @@ jobs:
27
27
  run: npm install
28
28
 
29
29
  - name: Run type checks
30
- run: npm run type-check
30
+ run: npm run typecheck
31
+
32
+ - name: Run tests
33
+ run: npm run test
34
+
35
+ - name: Build project
36
+ run: npm run build
31
37
 
32
38
  - name: Publish to npm
33
39
  run: npm publish --access public
package/CLAUDE.md ADDED
@@ -0,0 +1,78 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Common Commands
6
+
7
+ ### Development
8
+ - `npm install -D` - Install all dependencies including devDependencies
9
+ - `npm run dev` - Start the development server with file watching (uses tsx watch)
10
+ - `npm run build` - Build the TypeScript project and generate CLI binary (bin/cli.mjs)
11
+
12
+ ### Testing
13
+ - `npm test` - Run all tests once with Vitest
14
+ - `npm run test:dev` - Run tests in watch mode
15
+ - Run a specific test file: `npx vitest run src/openapi/__tests__/parser.test.ts`
16
+
17
+ ### Code Quality
18
+ - `npm run lint` - Check code formatting with ESLint
19
+ - `npm run lint:fix` - Auto-fix formatting issues with ESLint
20
+ - `npm run format` - Auto-fix formatting issues with Prettier
21
+ - `npm run typecheck` - Run TypeScript type checking without emitting files
22
+
23
+ ### Utility Scripts
24
+ - `npm run parse-openapi` - Parse OpenAPI specification
25
+
26
+ ## Architecture Overview
27
+
28
+ This is an MCP (Model Context Protocol) server that bridges Anytype's API with AI assistants. The architecture follows a proxy pattern where OpenAPI specifications are dynamically converted to MCP tools.
29
+
30
+ ### Core Components
31
+
32
+ **MCP Proxy Layer (`src/mcp/proxy.ts`)**
33
+ - Central orchestrator that implements the MCP server protocol
34
+ - Converts OpenAPI operations to MCP tools dynamically at runtime
35
+ - Handles tool listing and execution through the MCP protocol
36
+ - Maintains a lookup table mapping MCP tool names to OpenAPI operations
37
+
38
+ **OpenAPI Parser (`src/openapi/parser.ts`)**
39
+ - Converts OpenAPI schemas to JSON Schema format for MCP compatibility
40
+ - Handles $ref resolution with cycle detection
41
+ - Supports multipart/form-data for file uploads
42
+ - Generates MCP tool definitions from OpenAPI paths and operations
43
+
44
+ **HTTP Client (`src/client/http-client.ts`)**
45
+ - Built on openapi-client-axios for OpenAPI-aware HTTP requests
46
+ - Handles authentication headers from environment variables
47
+ - Supports file uploads via FormData
48
+ - Executes OpenAPI operations with proper parameter mapping
49
+
50
+ **Server Initialization (`src/init-server.ts`)**
51
+ - Loads OpenAPI spec from URL (default: local Anytype API) or file
52
+ - Initializes the MCP proxy with the spec
53
+ - Connects to stdio transport for communication
54
+
55
+ ### Key Design Patterns
56
+
57
+ 1. **Dynamic Tool Generation**: Tools are not hardcoded but generated from the OpenAPI spec at runtime, making the server adaptable to API changes.
58
+
59
+ 2. **Header Injection**: Authentication and version headers are parsed from `OPENAPI_MCP_HEADERS` environment variable and injected into all requests.
60
+
61
+ 3. **Operation Mapping**: Each OpenAPI operation becomes an MCP tool with a naming convention: `{tag}-{operationId}`.
62
+
63
+ 4. **Schema Caching**: The parser maintains a cache of resolved schemas to handle circular references and improve performance.
64
+
65
+ ## Testing Strategy
66
+
67
+ Tests use Vitest and are colocated with source files in `__tests__` directories. Key test areas:
68
+ - OpenAPI to MCP conversion logic
69
+ - HTTP client behavior including file uploads
70
+ - MCP proxy tool execution
71
+ - Multipart form data handling
72
+
73
+ ## Code Style
74
+
75
+ - Prettier with 120 character line width
76
+ - Double quotes for strings
77
+ - Automatic import organization via prettier-plugin-organize-imports
78
+ - TypeScript strict mode enabled
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Snaggle.ai
3
+ Copyright (c) 2023 Any Association
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions:
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
14
14
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
21
+ OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -38,7 +38,9 @@ npx -y @anyproto/anytype-mcp get-key
38
38
 
39
39
  ### 2. Configure Your MCP Client
40
40
 
41
- Add the following configuration to your MCP client settings:
41
+ #### Claude Desktop, Cursor, Windsurf, Raycast, etc.
42
+
43
+ Add the following configuration to your MCP client settings after replacing `<YOUR_API_KEY>` with your actual API key:
42
44
 
43
45
  ```json
44
46
  {
@@ -54,7 +56,15 @@ Add the following configuration to your MCP client settings:
54
56
  }
55
57
  ```
56
58
 
57
- > **Tip:** After creating an API key in Anytype, you can copy a ready-to-use configuration snippet with your API key already filled in from the API Keys section.
59
+ > **Tip:** After creating an API key in Anytype, you can copy that ready-to-use configuration snippet with your API key already filled in from the API Keys section.
60
+
61
+ #### Claude Code (CLI)
62
+
63
+ Run this command to add the Anytype MCP server after replacing `<YOUR_API_KEY>` with your actual API key:
64
+
65
+ ```bash
66
+ claude mcp add anytype -e OPENAPI_MCP_HEADERS='{"Authorization":"Bearer <YOUR_API_KEY>", "Anytype-Version":"2025-05-20"}' -s user -- npx -y @anyproto/anytype-mcp
67
+ ```
58
68
 
59
69
  <details>
60
70
  <summary>Alternative: Global Installation</summary>