mudbase-mcp-server 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +118 -0
- package/dist/client.d.ts +117 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +213 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +16 -0
- package/dist/server.js.map +1 -0
- package/dist/toolResult.d.ts +8 -0
- package/dist/toolResult.d.ts.map +1 -0
- package/dist/toolResult.js +41 -0
- package/dist/toolResult.js.map +1 -0
- package/dist/tools/collections.d.ts +4 -0
- package/dist/tools/collections.d.ts.map +1 -0
- package/dist/tools/collections.js +18 -0
- package/dist/tools/collections.js.map +1 -0
- package/dist/tools/documents.d.ts +4 -0
- package/dist/tools/documents.d.ts.map +1 -0
- package/dist/tools/documents.js +69 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/search.d.ts +4 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +28 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/storage.d.ts +4 -0
- package/dist/tools/storage.d.ts.map +1 -0
- package/dist/tools/storage.js +93 -0
- package/dist/tools/storage.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mudbase Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# mudbase-mcp-server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that exposes Mudbase's database, storage, and search
|
|
4
|
+
capabilities as tools for Claude Code, Claude Desktop, and any other MCP client.
|
|
5
|
+
|
|
6
|
+
Every request is authenticated with a Mudbase API key, so this connects your assistant directly
|
|
7
|
+
to real data in your own Mudbase project: list and query collections, read and write documents,
|
|
8
|
+
search across a project, and manage files in storage.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- A Mudbase account and project. If you don't have one yet, create one at
|
|
13
|
+
[cloud.mudbase.dev](https://cloud.mudbase.dev).
|
|
14
|
+
- An API key for that project, generated from your project's API Keys settings.
|
|
15
|
+
- Node.js 18 or newer (only needed to run `npx`; most MCP clients already bundle Node).
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
No install step is required. Point your MCP client at `npx mudbase-mcp-server` and it will
|
|
20
|
+
download and run the latest version on demand.
|
|
21
|
+
|
|
22
|
+
### Claude Code
|
|
23
|
+
|
|
24
|
+
Add this to your Claude Code MCP configuration:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"mcpServers": {
|
|
29
|
+
"mudbase": {
|
|
30
|
+
"command": "npx",
|
|
31
|
+
"args": ["mudbase-mcp-server"],
|
|
32
|
+
"env": { "MUDBASE_API_KEY": "ak_..." }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Replace `ak_...` with a real API key from your Mudbase project settings. Restart Claude Code (or
|
|
39
|
+
reload MCP servers) and the `mudbase_*` tools become available.
|
|
40
|
+
|
|
41
|
+
### Other MCP clients
|
|
42
|
+
|
|
43
|
+
Any client that can launch an MCP server over stdio works the same way: run `npx
|
|
44
|
+
mudbase-mcp-server` as the command, with `MUDBASE_API_KEY` set in its environment. Consult your
|
|
45
|
+
client's own docs for where to put the `command` / `args` / `env` fields; the shape above is the
|
|
46
|
+
common one.
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
| Environment variable | Required | Description |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `MUDBASE_API_KEY` | Yes | Your Mudbase project API key. The server refuses to start without it and prints a clear error explaining how to set it. |
|
|
53
|
+
| `MUDBASE_BASE_URL` | No | Override the API base URL (defaults to `https://cloud.mudbase.dev`). Only needed for a self-hosted or non-default deployment. |
|
|
54
|
+
|
|
55
|
+
The API key is read from the environment only. It is never logged, never written to disk, and
|
|
56
|
+
never hardcoded anywhere in this package.
|
|
57
|
+
|
|
58
|
+
## Available tools
|
|
59
|
+
|
|
60
|
+
**Collections** (read-only schema access)
|
|
61
|
+
|
|
62
|
+
- `mudbase_list_collections`: list every collection in a project, with each field's declared type.
|
|
63
|
+
- `mudbase_get_collection`: get one collection's full field schema and permission settings.
|
|
64
|
+
|
|
65
|
+
**Documents** (collection data)
|
|
66
|
+
|
|
67
|
+
- `mudbase_list_documents`: list documents in a collection, with pagination, sorting, and a JSON filter.
|
|
68
|
+
- `mudbase_get_document`: fetch a single document by ID.
|
|
69
|
+
- `mudbase_create_document`: create a new document.
|
|
70
|
+
- `mudbase_update_document`: partially update an existing document.
|
|
71
|
+
- `mudbase_delete_document`: permanently delete a document.
|
|
72
|
+
|
|
73
|
+
**Search**
|
|
74
|
+
|
|
75
|
+
- `mudbase_search_documents`: full-text search across a project, optionally scoped to specific collections or fields.
|
|
76
|
+
|
|
77
|
+
**Storage**
|
|
78
|
+
|
|
79
|
+
- `mudbase_list_buckets`: list the storage buckets in a project.
|
|
80
|
+
- `mudbase_list_files`: list files in a bucket, with search and MIME-type filters.
|
|
81
|
+
- `mudbase_get_file`: get metadata for a single stored file.
|
|
82
|
+
- `mudbase_upload_file`: upload a file from base64-encoded content.
|
|
83
|
+
- `mudbase_delete_file`: permanently delete a file.
|
|
84
|
+
- `mudbase_get_file_download_url`: generate a time-limited signed download URL for a file.
|
|
85
|
+
|
|
86
|
+
Every tool is a thin, typed wrapper over one real Mudbase API endpoint; none of them add new
|
|
87
|
+
business logic beyond request shaping and error normalization. `mudbase_delete_document` and
|
|
88
|
+
`mudbase_delete_file` are marked destructive in their tool metadata so a client can prompt for
|
|
89
|
+
confirmation before calling them.
|
|
90
|
+
|
|
91
|
+
## How errors are reported
|
|
92
|
+
|
|
93
|
+
A failed API call (invalid API key, missing project, validation error, rate limit, and so on)
|
|
94
|
+
never crashes the server or throws an unhandled exception. It comes back to the MCP client as a
|
|
95
|
+
normal tool result with `isError: true` and a JSON body describing what went wrong, for example:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"error": "Mudbase rejected this API key. Check that MUDBASE_API_KEY is a valid, active key with access to this project.",
|
|
100
|
+
"status": 401,
|
|
101
|
+
"code": "unauthorized"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm install
|
|
109
|
+
npm run build # compile TypeScript to dist/
|
|
110
|
+
npm run dev # run the server directly from source with tsx
|
|
111
|
+
npm test # run the unit test suite
|
|
112
|
+
npm run typecheck # tsc --noEmit
|
|
113
|
+
npm run lint # eslint
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
MIT. Built by the Mudbase Team.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** Default Mudbase API base URL. Override with MUDBASE_BASE_URL for self-hosted or staging use. */
|
|
2
|
+
export declare const DEFAULT_BASE_URL = "https://cloud.mudbase.dev";
|
|
3
|
+
/** Normalized error thrown for any failed Mudbase API call. */
|
|
4
|
+
export declare class MudbaseApiError extends Error {
|
|
5
|
+
readonly status?: number;
|
|
6
|
+
readonly code?: string;
|
|
7
|
+
readonly details?: unknown;
|
|
8
|
+
constructor(message: string, options?: {
|
|
9
|
+
status?: number;
|
|
10
|
+
code?: string;
|
|
11
|
+
details?: unknown;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export interface MudbaseClientOptions {
|
|
15
|
+
/** A Mudbase project or organization API key (X-API-Key). */
|
|
16
|
+
apiKey: string;
|
|
17
|
+
/** Override the API base URL. Defaults to https://cloud.mudbase.dev. */
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
}
|
|
20
|
+
interface UploadFileParams {
|
|
21
|
+
projectId: string;
|
|
22
|
+
bucketId: string;
|
|
23
|
+
filename: string;
|
|
24
|
+
contentBase64: string;
|
|
25
|
+
mimeType?: string;
|
|
26
|
+
isPublic?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Thin, typed wrapper over the public Mudbase REST API. Every method maps to exactly one
|
|
30
|
+
* documented endpoint; no client-side business logic beyond request shaping and error
|
|
31
|
+
* normalization. Authenticates every request with the caller's API key, matching the same
|
|
32
|
+
* X-API-Key header the Mudbase SDKs and REST docs use for programmatic access.
|
|
33
|
+
*/
|
|
34
|
+
export declare class MudbaseClient {
|
|
35
|
+
private readonly http;
|
|
36
|
+
constructor(options: MudbaseClientOptions);
|
|
37
|
+
private request;
|
|
38
|
+
listCollections(params: {
|
|
39
|
+
projectId: string;
|
|
40
|
+
}): Promise<unknown>;
|
|
41
|
+
getCollection(params: {
|
|
42
|
+
projectId: string;
|
|
43
|
+
collectionId: string;
|
|
44
|
+
}): Promise<unknown>;
|
|
45
|
+
listDocuments(params: {
|
|
46
|
+
projectId: string;
|
|
47
|
+
collectionId: string;
|
|
48
|
+
page?: number;
|
|
49
|
+
limit?: number;
|
|
50
|
+
sort?: string;
|
|
51
|
+
filter?: string;
|
|
52
|
+
}): Promise<unknown>;
|
|
53
|
+
getDocument(params: {
|
|
54
|
+
projectId: string;
|
|
55
|
+
collectionId: string;
|
|
56
|
+
documentId: string;
|
|
57
|
+
}): Promise<unknown>;
|
|
58
|
+
createDocument(params: {
|
|
59
|
+
projectId: string;
|
|
60
|
+
collectionId: string;
|
|
61
|
+
data: Record<string, unknown>;
|
|
62
|
+
}): Promise<unknown>;
|
|
63
|
+
updateDocument(params: {
|
|
64
|
+
projectId: string;
|
|
65
|
+
collectionId: string;
|
|
66
|
+
documentId: string;
|
|
67
|
+
data: Record<string, unknown>;
|
|
68
|
+
}): Promise<unknown>;
|
|
69
|
+
deleteDocument(params: {
|
|
70
|
+
projectId: string;
|
|
71
|
+
collectionId: string;
|
|
72
|
+
documentId: string;
|
|
73
|
+
}): Promise<unknown>;
|
|
74
|
+
searchDocuments(params: {
|
|
75
|
+
projectId: string;
|
|
76
|
+
query: string;
|
|
77
|
+
collections?: string;
|
|
78
|
+
fields?: string;
|
|
79
|
+
page?: number;
|
|
80
|
+
limit?: number;
|
|
81
|
+
}): Promise<unknown>;
|
|
82
|
+
listBuckets(params: {
|
|
83
|
+
projectId: string;
|
|
84
|
+
search?: string;
|
|
85
|
+
page?: number;
|
|
86
|
+
limit?: number;
|
|
87
|
+
}): Promise<unknown>;
|
|
88
|
+
listFiles(params: {
|
|
89
|
+
projectId: string;
|
|
90
|
+
bucketId: string;
|
|
91
|
+
search?: string;
|
|
92
|
+
type?: string;
|
|
93
|
+
page?: number;
|
|
94
|
+
limit?: number;
|
|
95
|
+
}): Promise<unknown>;
|
|
96
|
+
getFile(params: {
|
|
97
|
+
projectId: string;
|
|
98
|
+
bucketId: string;
|
|
99
|
+
fileId: string;
|
|
100
|
+
}): Promise<unknown>;
|
|
101
|
+
deleteFile(params: {
|
|
102
|
+
projectId: string;
|
|
103
|
+
bucketId: string;
|
|
104
|
+
fileId: string;
|
|
105
|
+
}): Promise<unknown>;
|
|
106
|
+
getFileDownloadUrl(params: {
|
|
107
|
+
projectId: string;
|
|
108
|
+
bucketId: string;
|
|
109
|
+
fileId: string;
|
|
110
|
+
expiresIn?: number;
|
|
111
|
+
}): Promise<unknown>;
|
|
112
|
+
uploadFile(params: UploadFileParams): Promise<unknown>;
|
|
113
|
+
}
|
|
114
|
+
/** Turn any thrown error from an HTTP call into a normalized, human-readable MudbaseApiError. */
|
|
115
|
+
export declare function toMudbaseApiError(error: unknown): MudbaseApiError;
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAE5D,+DAA+D;AAC/D,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,OAAO,E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MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUpB,OAAO,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1F,UAAU,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAS7F,kBAAkB,CAAC,MAAM,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,OAAO,CAAC;IAUd,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CA0B7D;AAED,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CA0CjE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import axios, { isAxiosError } from "axios";
|
|
2
|
+
import FormData from "form-data";
|
|
3
|
+
/** Default Mudbase API base URL. Override with MUDBASE_BASE_URL for self-hosted or staging use. */
|
|
4
|
+
export const DEFAULT_BASE_URL = "https://cloud.mudbase.dev";
|
|
5
|
+
/** Normalized error thrown for any failed Mudbase API call. */
|
|
6
|
+
export class MudbaseApiError extends Error {
|
|
7
|
+
status;
|
|
8
|
+
code;
|
|
9
|
+
details;
|
|
10
|
+
constructor(message, options = {}) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "MudbaseApiError";
|
|
13
|
+
this.status = options.status;
|
|
14
|
+
this.code = options.code;
|
|
15
|
+
this.details = options.details;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thin, typed wrapper over the public Mudbase REST API. Every method maps to exactly one
|
|
20
|
+
* documented endpoint; no client-side business logic beyond request shaping and error
|
|
21
|
+
* normalization. Authenticates every request with the caller's API key, matching the same
|
|
22
|
+
* X-API-Key header the Mudbase SDKs and REST docs use for programmatic access.
|
|
23
|
+
*/
|
|
24
|
+
export class MudbaseClient {
|
|
25
|
+
http;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
if (!options.apiKey || options.apiKey.trim().length === 0) {
|
|
28
|
+
throw new Error("A Mudbase API key is required. Set the MUDBASE_API_KEY environment variable to a key " +
|
|
29
|
+
"from your Mudbase project settings.");
|
|
30
|
+
}
|
|
31
|
+
const baseURL = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
32
|
+
this.http = axios.create({
|
|
33
|
+
baseURL,
|
|
34
|
+
timeout: 30_000,
|
|
35
|
+
headers: {
|
|
36
|
+
"X-API-Key": options.apiKey,
|
|
37
|
+
Accept: "application/json",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async request(config) {
|
|
42
|
+
try {
|
|
43
|
+
const response = await this.http.request(config);
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw toMudbaseApiError(error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// ---- Collections (read-only schema access) ----
|
|
51
|
+
listCollections(params) {
|
|
52
|
+
return this.request({
|
|
53
|
+
method: "GET",
|
|
54
|
+
url: `/api/schemas/projects/${encodeURIComponent(params.projectId)}/collections`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
getCollection(params) {
|
|
58
|
+
return this.request({
|
|
59
|
+
method: "GET",
|
|
60
|
+
url: `/api/schemas/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// ---- Documents (collection data CRUD) ----
|
|
64
|
+
listDocuments(params) {
|
|
65
|
+
return this.request({
|
|
66
|
+
method: "GET",
|
|
67
|
+
url: `/api/data/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}/data`,
|
|
68
|
+
params: {
|
|
69
|
+
page: params.page,
|
|
70
|
+
limit: params.limit,
|
|
71
|
+
sort: params.sort,
|
|
72
|
+
filter: params.filter,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
getDocument(params) {
|
|
77
|
+
return this.request({
|
|
78
|
+
method: "GET",
|
|
79
|
+
url: `/api/data/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}/data/${encodeURIComponent(params.documentId)}`,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
createDocument(params) {
|
|
83
|
+
return this.request({
|
|
84
|
+
method: "POST",
|
|
85
|
+
url: `/api/data/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}/data`,
|
|
86
|
+
data: params.data,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
updateDocument(params) {
|
|
90
|
+
return this.request({
|
|
91
|
+
method: "PATCH",
|
|
92
|
+
url: `/api/data/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}/data/${encodeURIComponent(params.documentId)}`,
|
|
93
|
+
data: params.data,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
deleteDocument(params) {
|
|
97
|
+
return this.request({
|
|
98
|
+
method: "DELETE",
|
|
99
|
+
url: `/api/data/projects/${encodeURIComponent(params.projectId)}/collections/${encodeURIComponent(params.collectionId)}/data/${encodeURIComponent(params.documentId)}`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
// ---- Search ----
|
|
103
|
+
searchDocuments(params) {
|
|
104
|
+
return this.request({
|
|
105
|
+
method: "GET",
|
|
106
|
+
url: `/api/search/projects/${encodeURIComponent(params.projectId)}/search`,
|
|
107
|
+
params: {
|
|
108
|
+
q: params.query,
|
|
109
|
+
collections: params.collections,
|
|
110
|
+
fields: params.fields,
|
|
111
|
+
page: params.page,
|
|
112
|
+
limit: params.limit,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
// ---- Storage (buckets and files) ----
|
|
117
|
+
listBuckets(params) {
|
|
118
|
+
return this.request({
|
|
119
|
+
method: "GET",
|
|
120
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets`,
|
|
121
|
+
params: { search: params.search, page: params.page, limit: params.limit },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
listFiles(params) {
|
|
125
|
+
return this.request({
|
|
126
|
+
method: "GET",
|
|
127
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets/${encodeURIComponent(params.bucketId)}/files`,
|
|
128
|
+
params: { search: params.search, type: params.type, page: params.page, limit: params.limit },
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
getFile(params) {
|
|
132
|
+
return this.request({
|
|
133
|
+
method: "GET",
|
|
134
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets/${encodeURIComponent(params.bucketId)}/files/${encodeURIComponent(params.fileId)}`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
deleteFile(params) {
|
|
138
|
+
return this.request({
|
|
139
|
+
method: "DELETE",
|
|
140
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets/${encodeURIComponent(params.bucketId)}/files/${encodeURIComponent(params.fileId)}`,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getFileDownloadUrl(params) {
|
|
144
|
+
return this.request({
|
|
145
|
+
method: "POST",
|
|
146
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets/${encodeURIComponent(params.bucketId)}/files/${encodeURIComponent(params.fileId)}/signed-url`,
|
|
147
|
+
data: { expiresIn: params.expiresIn },
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async uploadFile(params) {
|
|
151
|
+
const buffer = Buffer.from(params.contentBase64, "base64");
|
|
152
|
+
if (buffer.length === 0) {
|
|
153
|
+
throw new MudbaseApiError("contentBase64 decoded to an empty file. Nothing was uploaded.", {
|
|
154
|
+
code: "empty_file",
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const form = new FormData();
|
|
158
|
+
form.append("files", buffer, {
|
|
159
|
+
filename: params.filename,
|
|
160
|
+
contentType: params.mimeType || "application/octet-stream",
|
|
161
|
+
});
|
|
162
|
+
if (params.isPublic !== undefined) {
|
|
163
|
+
form.append("isPublic", String(params.isPublic));
|
|
164
|
+
}
|
|
165
|
+
return this.request({
|
|
166
|
+
method: "POST",
|
|
167
|
+
url: `/api/bucket/projects/${encodeURIComponent(params.projectId)}/buckets/${encodeURIComponent(params.bucketId)}/files`,
|
|
168
|
+
data: form,
|
|
169
|
+
headers: form.getHeaders(),
|
|
170
|
+
maxBodyLength: Infinity,
|
|
171
|
+
maxContentLength: Infinity,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** Turn any thrown error from an HTTP call into a normalized, human-readable MudbaseApiError. */
|
|
176
|
+
export function toMudbaseApiError(error) {
|
|
177
|
+
if (error instanceof MudbaseApiError) {
|
|
178
|
+
return error;
|
|
179
|
+
}
|
|
180
|
+
if (isAxiosError(error)) {
|
|
181
|
+
const status = error.response?.status;
|
|
182
|
+
const body = error.response?.data;
|
|
183
|
+
const bodyMessage = typeof body?.error === "string" ? body.error : undefined;
|
|
184
|
+
const code = typeof body?.code === "string" ? body.code : undefined;
|
|
185
|
+
if (error.code === "ECONNABORTED") {
|
|
186
|
+
return new MudbaseApiError("The request to Mudbase timed out.", { code: "timeout" });
|
|
187
|
+
}
|
|
188
|
+
if (!error.response) {
|
|
189
|
+
return new MudbaseApiError(`Could not reach the Mudbase API (${error.message}). Check your network connection and the base URL.`, { code: "network_error" });
|
|
190
|
+
}
|
|
191
|
+
if (status === 401 || status === 403) {
|
|
192
|
+
return new MudbaseApiError(bodyMessage ??
|
|
193
|
+
"Mudbase rejected this API key. Check that MUDBASE_API_KEY is a valid, active key with access to this project.", { status, code: code ?? "unauthorized", details: body });
|
|
194
|
+
}
|
|
195
|
+
if (status === 429) {
|
|
196
|
+
return new MudbaseApiError(bodyMessage ?? "Rate limited by Mudbase. Slow down and retry.", {
|
|
197
|
+
status,
|
|
198
|
+
code: code ?? "rate_limited",
|
|
199
|
+
details: body,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return new MudbaseApiError(bodyMessage ?? `Mudbase API request failed with status ${status}.`, {
|
|
203
|
+
status,
|
|
204
|
+
code,
|
|
205
|
+
details: body,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (error instanceof Error) {
|
|
209
|
+
return new MudbaseApiError(error.message);
|
|
210
|
+
}
|
|
211
|
+
return new MudbaseApiError("An unknown error occurred while calling the Mudbase API.");
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA+C,YAAY,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,mGAAmG;AACnG,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D,+DAA+D;AAC/D,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,OAAO,CAAW;IAE3B,YAAY,OAAe,EAAE,UAAiE,EAAE;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,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AAG,EAAE;YAC7F,MAAM;YACN,IAAI;YACJ,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACL,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,eAAe,CAAC,0DAA0D,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createServer } from "./server.js";
|
|
4
|
+
import { DEFAULT_BASE_URL } from "./client.js";
|
|
5
|
+
async function main() {
|
|
6
|
+
const apiKey = process.env.MUDBASE_API_KEY;
|
|
7
|
+
if (!apiKey || apiKey.trim().length === 0) {
|
|
8
|
+
console.error("[mudbase-mcp-server] MUDBASE_API_KEY is not set. Add it to your MCP client's env config, e.g.:\n" +
|
|
9
|
+
' { "mcpServers": { "mudbase": { "command": "npx", "args": ["mudbase-mcp-server"], ' +
|
|
10
|
+
'"env": { "MUDBASE_API_KEY": "ak_..." } } } }\n' +
|
|
11
|
+
"Get an API key from your Mudbase project settings at https://cloud.mudbase.dev.");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const baseUrl = process.env.MUDBASE_BASE_URL || DEFAULT_BASE_URL;
|
|
15
|
+
const server = createServer({ apiKey, baseUrl });
|
|
16
|
+
const transport = new StdioServerTransport();
|
|
17
|
+
await server.connect(transport);
|
|
18
|
+
console.error(`[mudbase-mcp-server] running on stdio, base URL ${baseUrl}`);
|
|
19
|
+
}
|
|
20
|
+
main().catch((error) => {
|
|
21
|
+
console.error("[mudbase-mcp-server] fatal error:", error);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC3C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,KAAK,CACX,kGAAkG;YAChG,qFAAqF;YACrF,gDAAgD;YAChD,iFAAiF,CACpF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,gBAAgB,CAAC;IAEjE,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,CAAC,KAAK,CAAC,mDAAmD,OAAO,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
export declare const SERVER_NAME = "mudbase-mcp-server";
|
|
3
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
4
|
+
export interface CreateServerOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Build a fully configured, not-yet-connected Mudbase MCP server. */
|
|
9
|
+
export declare function createServer(options: CreateServerOptions): McpServer;
|
|
10
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,eAAO,MAAM,WAAW,uBAAuB,CAAC;AAChD,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAWpE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { MudbaseClient, DEFAULT_BASE_URL } from "./client.js";
|
|
3
|
+
import { registerAllTools } from "./tools/index.js";
|
|
4
|
+
export const SERVER_NAME = "mudbase-mcp-server";
|
|
5
|
+
export const SERVER_VERSION = "0.1.0";
|
|
6
|
+
/** Build a fully configured, not-yet-connected Mudbase MCP server. */
|
|
7
|
+
export function createServer(options) {
|
|
8
|
+
const client = new MudbaseClient({ apiKey: options.apiKey, baseUrl: options.baseUrl ?? DEFAULT_BASE_URL });
|
|
9
|
+
const server = new McpServer({
|
|
10
|
+
name: SERVER_NAME,
|
|
11
|
+
version: SERVER_VERSION,
|
|
12
|
+
});
|
|
13
|
+
registerAllTools(server, client);
|
|
14
|
+
return server;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAOtC,sEAAsE;AACtE,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC,CAAC;IAE3G,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;KACxB,CAAC,CAAC;IAEH,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
/** Wrap a successful tool result as pretty-printed JSON text content. */
|
|
3
|
+
export declare function toolSuccess(data: unknown): CallToolResult;
|
|
4
|
+
/** Wrap a failed tool call as an MCP error result, never as a thrown exception. */
|
|
5
|
+
export declare function toolFailure(error: unknown): CallToolResult;
|
|
6
|
+
/** Run a tool handler, converting any thrown error into a well-formed MCP error result. */
|
|
7
|
+
export declare function runTool(fn: () => Promise<unknown>): Promise<CallToolResult>;
|
|
8
|
+
//# sourceMappingURL=toolResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolResult.d.ts","sourceRoot":"","sources":["../src/toolResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,CASzD;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAc1D;AAED,2FAA2F;AAC3F,wBAAsB,OAAO,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAOjF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MudbaseApiError, toMudbaseApiError } from "./client.js";
|
|
2
|
+
/** Wrap a successful tool result as pretty-printed JSON text content. */
|
|
3
|
+
export function toolSuccess(data) {
|
|
4
|
+
return {
|
|
5
|
+
content: [
|
|
6
|
+
{
|
|
7
|
+
type: "text",
|
|
8
|
+
text: JSON.stringify(data, null, 2),
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Wrap a failed tool call as an MCP error result, never as a thrown exception. */
|
|
14
|
+
export function toolFailure(error) {
|
|
15
|
+
const apiError = error instanceof MudbaseApiError ? error : toMudbaseApiError(error);
|
|
16
|
+
const payload = { error: apiError.message };
|
|
17
|
+
if (apiError.status !== undefined)
|
|
18
|
+
payload.status = apiError.status;
|
|
19
|
+
if (apiError.code !== undefined)
|
|
20
|
+
payload.code = apiError.code;
|
|
21
|
+
return {
|
|
22
|
+
isError: true,
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: JSON.stringify(payload, null, 2),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Run a tool handler, converting any thrown error into a well-formed MCP error result. */
|
|
32
|
+
export async function runTool(fn) {
|
|
33
|
+
try {
|
|
34
|
+
const result = await fn();
|
|
35
|
+
return toolSuccess(result);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return toolFailure(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=toolResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolResult.js","sourceRoot":"","sources":["../src/toolResult.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;aACpC;SACF;KACF,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,MAAM,QAAQ,GAAG,KAAK,YAAY,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACrF,MAAM,OAAO,GAA4B,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IACrE,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpE,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC9D,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;aACvC;SACF;KACF,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,EAA0B;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/tools/collections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAuBtF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runTool } from "../toolResult.js";
|
|
3
|
+
const projectId = z.string().min(1).describe("The Mudbase project ID.");
|
|
4
|
+
const collectionId = z.string().min(1).describe("The collection ID within the project.");
|
|
5
|
+
export function registerCollectionTools(server, client) {
|
|
6
|
+
server.registerTool("mudbase_list_collections", {
|
|
7
|
+
title: "List Mudbase collections",
|
|
8
|
+
description: "List every collection (schema) defined in a Mudbase project, including each field's name and type. " +
|
|
9
|
+
"Call this before reading or writing documents to see what collections and fields actually exist.",
|
|
10
|
+
inputSchema: { projectId },
|
|
11
|
+
}, async (args) => runTool(() => client.listCollections({ projectId: args.projectId })));
|
|
12
|
+
server.registerTool("mudbase_get_collection", {
|
|
13
|
+
title: "Get a Mudbase collection's schema",
|
|
14
|
+
description: "Get the full field schema and permission settings for one collection in a Mudbase project.",
|
|
15
|
+
inputSchema: { projectId, collectionId },
|
|
16
|
+
}, async (args) => runTool(() => client.getCollection({ projectId: args.projectId, collectionId: args.collectionId })));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/tools/collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;AACxE,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC;AAEzF,MAAM,UAAU,uBAAuB,CAAC,MAAiB,EAAE,MAAqB;IAC9E,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EACT,qGAAqG;YACrG,kGAAkG;QACpG,WAAW,EAAE,EAAE,SAAS,EAAE;KAC3B,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CACrF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,mCAAmC;QAC1C,WAAW,EAAE,4FAA4F;QACzG,WAAW,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE;KACzC,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CACtG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAQlD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAuGpF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runTool } from "../toolResult.js";
|
|
3
|
+
const projectId = z.string().min(1).describe("The Mudbase project ID.");
|
|
4
|
+
const collectionId = z.string().min(1).describe("The collection ID to operate on.");
|
|
5
|
+
const documentId = z.string().min(1).describe("The document ID within the collection.");
|
|
6
|
+
const documentData = z.record(z.string(), z.unknown()).describe("The document fields as a plain JSON object.");
|
|
7
|
+
export function registerDocumentTools(server, client) {
|
|
8
|
+
server.registerTool("mudbase_list_documents", {
|
|
9
|
+
title: "List documents in a Mudbase collection",
|
|
10
|
+
description: "List documents in a Mudbase collection, with pagination, sorting, and an optional filter. " +
|
|
11
|
+
"'filter' is a JSON-encoded object using Mudbase's structured query operators, e.g. " +
|
|
12
|
+
'\'{"status":"active"}\' or \'{"age":{"$gte":18}}\'.',
|
|
13
|
+
inputSchema: {
|
|
14
|
+
projectId,
|
|
15
|
+
collectionId,
|
|
16
|
+
page: z.number().int().min(1).optional().describe("Page number, starting at 1. Defaults to 1."),
|
|
17
|
+
limit: z.number().int().min(1).max(100).optional().describe("Documents per page, max 100. Defaults to 20."),
|
|
18
|
+
sort: z
|
|
19
|
+
.string()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Sort field(s), e.g. '-createdAt' for newest first, or 'name' for ascending."),
|
|
22
|
+
filter: z.string().optional().describe("A JSON-encoded filter object using Mudbase's structured query operators."),
|
|
23
|
+
},
|
|
24
|
+
}, async (args) => runTool(() => client.listDocuments({
|
|
25
|
+
projectId: args.projectId,
|
|
26
|
+
collectionId: args.collectionId,
|
|
27
|
+
page: args.page,
|
|
28
|
+
limit: args.limit,
|
|
29
|
+
sort: args.sort,
|
|
30
|
+
filter: args.filter,
|
|
31
|
+
})));
|
|
32
|
+
server.registerTool("mudbase_get_document", {
|
|
33
|
+
title: "Get a single Mudbase document",
|
|
34
|
+
description: "Fetch a single document by ID from a Mudbase collection.",
|
|
35
|
+
inputSchema: { projectId, collectionId, documentId },
|
|
36
|
+
}, async (args) => runTool(() => client.getDocument({
|
|
37
|
+
projectId: args.projectId,
|
|
38
|
+
collectionId: args.collectionId,
|
|
39
|
+
documentId: args.documentId,
|
|
40
|
+
})));
|
|
41
|
+
server.registerTool("mudbase_create_document", {
|
|
42
|
+
title: "Create a Mudbase document",
|
|
43
|
+
description: "Create a new document in a Mudbase collection. 'data' must match the collection's declared field " +
|
|
44
|
+
"schema (see mudbase_get_collection). Fires the collection's configured webhooks and triggers.",
|
|
45
|
+
inputSchema: { projectId, collectionId, data: documentData },
|
|
46
|
+
}, async (args) => runTool(() => client.createDocument({ projectId: args.projectId, collectionId: args.collectionId, data: args.data })));
|
|
47
|
+
server.registerTool("mudbase_update_document", {
|
|
48
|
+
title: "Update a Mudbase document",
|
|
49
|
+
description: "Partially update an existing document. Only the fields included in 'data' are changed; omitted " +
|
|
50
|
+
"fields are left as-is.",
|
|
51
|
+
inputSchema: { projectId, collectionId, documentId, data: documentData },
|
|
52
|
+
}, async (args) => runTool(() => client.updateDocument({
|
|
53
|
+
projectId: args.projectId,
|
|
54
|
+
collectionId: args.collectionId,
|
|
55
|
+
documentId: args.documentId,
|
|
56
|
+
data: args.data,
|
|
57
|
+
})));
|
|
58
|
+
server.registerTool("mudbase_delete_document", {
|
|
59
|
+
title: "Delete a Mudbase document",
|
|
60
|
+
description: "Permanently delete a single document from a Mudbase collection. This cannot be undone.",
|
|
61
|
+
inputSchema: { projectId, collectionId, documentId },
|
|
62
|
+
annotations: { destructiveHint: true },
|
|
63
|
+
}, async (args) => runTool(() => client.deleteDocument({
|
|
64
|
+
projectId: args.projectId,
|
|
65
|
+
collectionId: args.collectionId,
|
|
66
|
+
documentId: args.documentId,
|
|
67
|
+
})));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/tools/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;AACxE,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kCAAkC,CAAC,CAAC;AACpF,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC,CAAC;AACxF,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,6CAA6C,CAAC,CAAC;AAE/G,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAqB;IAC5E,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,wCAAwC;QAC/C,WAAW,EACT,4FAA4F;YAC5F,qFAAqF;YACrF,qDAAqD;QACvD,WAAW,EAAE;YACX,SAAS;YACT,YAAY;YACZ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CA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AC,YAAY;QAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CACH,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { MudbaseClient } from "../client.js";
|
|
3
|
+
/** Register every Mudbase tool onto the given MCP server, bound to one authenticated client. */
|
|
4
|
+
export declare function registerAllTools(server: McpServer, client: MudbaseClient): void;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAMlD,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAK/E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerCollectionTools } from "./collections.js";
|
|
2
|
+
import { registerDocumentTools } from "./documents.js";
|
|
3
|
+
import { registerSearchTools } from "./search.js";
|
|
4
|
+
import { registerStorageTools } from "./storage.js";
|
|
5
|
+
/** Register every Mudbase tool onto the given MCP server, bound to one authenticated client. */
|
|
6
|
+
export function registerAllTools(server, client) {
|
|
7
|
+
registerCollectionTools(server, client);
|
|
8
|
+
registerDocumentTools(server, client);
|
|
9
|
+
registerSearchTools(server, client);
|
|
10
|
+
registerStorageTools(server, client);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,gGAAgG;AAChG,MAAM,UAAU,gBAAgB,CAAC,MAAiB,EAAE,MAAqB;IACvE,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAgClF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runTool } from "../toolResult.js";
|
|
3
|
+
export function registerSearchTools(server, client) {
|
|
4
|
+
server.registerTool("mudbase_search_documents", {
|
|
5
|
+
title: "Search across a Mudbase project",
|
|
6
|
+
description: "Full-text search across a Mudbase project's collections. Optionally scope to specific collections " +
|
|
7
|
+
"or fields.",
|
|
8
|
+
inputSchema: {
|
|
9
|
+
projectId: z.string().min(1).describe("The Mudbase project ID."),
|
|
10
|
+
query: z.string().min(1).max(100).describe("The search query, 1 to 100 characters."),
|
|
11
|
+
collections: z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("Comma-separated collection slugs to restrict the search to. Omit to search all."),
|
|
15
|
+
fields: z.string().optional().describe("Comma-separated field names to restrict matching to."),
|
|
16
|
+
page: z.number().int().min(1).optional().describe("Page number, starting at 1. Defaults to 1."),
|
|
17
|
+
limit: z.number().int().min(1).max(100).optional().describe("Results per page, max 100. Defaults to 20."),
|
|
18
|
+
},
|
|
19
|
+
}, async (args) => runTool(() => client.searchDocuments({
|
|
20
|
+
projectId: args.projectId,
|
|
21
|
+
query: args.query,
|
|
22
|
+
collections: args.collections,
|
|
23
|
+
fields: args.fields,
|
|
24
|
+
page: args.page,
|
|
25
|
+
limit: args.limit,
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,MAAqB;IAC1E,MAAM,CAAC,YAAY,CACjB,0BAA0B,EAC1B;QACE,KAAK,EAAE,iCAAiC;QACxC,WAAW,EACT,oGAAoG;YACpG,YAAY;QACd,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;YAChE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC;YACpF,WAAW,EAAE,CAAC;iBACX,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,iFAAiF,CAAC;YAC9F,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;YAC9F,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;YAC/F,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;SAC1G;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,OAAO,CAAC,GAAG,EAAE,CACX,MAAM,CAAC,eAAe,CAAC;QACrB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CACH,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOlD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAkInF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runTool } from "../toolResult.js";
|
|
3
|
+
const projectId = z.string().min(1).describe("The Mudbase project ID.");
|
|
4
|
+
const bucketId = z.string().min(1).describe("The storage bucket ID within the project.");
|
|
5
|
+
const fileId = z.string().min(1).describe("The file ID within the bucket.");
|
|
6
|
+
export function registerStorageTools(server, client) {
|
|
7
|
+
server.registerTool("mudbase_list_buckets", {
|
|
8
|
+
title: "List Mudbase storage buckets",
|
|
9
|
+
description: "List the storage buckets configured in a Mudbase project.",
|
|
10
|
+
inputSchema: {
|
|
11
|
+
projectId,
|
|
12
|
+
search: z.string().optional().describe("Filter buckets whose name matches this text."),
|
|
13
|
+
page: z.number().int().min(1).optional().describe("Page number, starting at 1. Defaults to 1."),
|
|
14
|
+
limit: z.number().int().min(1).max(100).optional().describe("Buckets per page, max 100. Defaults to 20."),
|
|
15
|
+
},
|
|
16
|
+
}, async (args) => runTool(() => client.listBuckets({ projectId: args.projectId, search: args.search, page: args.page, limit: args.limit })));
|
|
17
|
+
server.registerTool("mudbase_list_files", {
|
|
18
|
+
title: "List files in a Mudbase bucket",
|
|
19
|
+
description: "List the files stored in one Mudbase storage bucket, with optional search and MIME type filter.",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
projectId,
|
|
22
|
+
bucketId,
|
|
23
|
+
search: z.string().optional().describe("Filter files whose name matches this text."),
|
|
24
|
+
type: z.string().optional().describe("Filter by exact MIME type, e.g. 'image/png'."),
|
|
25
|
+
page: z.number().int().min(1).optional().describe("Page number, starting at 1. Defaults to 1."),
|
|
26
|
+
limit: z.number().int().min(1).max(100).optional().describe("Files per page, max 100. Defaults to 20."),
|
|
27
|
+
},
|
|
28
|
+
}, async (args) => runTool(() => client.listFiles({
|
|
29
|
+
projectId: args.projectId,
|
|
30
|
+
bucketId: args.bucketId,
|
|
31
|
+
search: args.search,
|
|
32
|
+
type: args.type,
|
|
33
|
+
page: args.page,
|
|
34
|
+
limit: args.limit,
|
|
35
|
+
})));
|
|
36
|
+
server.registerTool("mudbase_get_file", {
|
|
37
|
+
title: "Get Mudbase file metadata",
|
|
38
|
+
description: "Get metadata (name, size, MIME type, visibility, timestamps) for a single stored file.",
|
|
39
|
+
inputSchema: { projectId, bucketId, fileId },
|
|
40
|
+
}, async (args) => runTool(() => client.getFile({ projectId: args.projectId, bucketId: args.bucketId, fileId: args.fileId })));
|
|
41
|
+
server.registerTool("mudbase_upload_file", {
|
|
42
|
+
title: "Upload a file to Mudbase storage",
|
|
43
|
+
description: "Upload a file to a Mudbase storage bucket. Provide the file content as a base64-encoded string. " +
|
|
44
|
+
"Best for small to moderate files (text, small images, JSON, documents) passed inline; not intended " +
|
|
45
|
+
"for very large binaries.",
|
|
46
|
+
inputSchema: {
|
|
47
|
+
projectId,
|
|
48
|
+
bucketId,
|
|
49
|
+
filename: z.string().min(1).describe("The file name to store, including its extension."),
|
|
50
|
+
contentBase64: z.string().min(1).describe("The file's raw bytes, base64-encoded."),
|
|
51
|
+
mimeType: z.string().optional().describe("The file's MIME type, e.g. 'image/png' or 'application/pdf'."),
|
|
52
|
+
isPublic: z
|
|
53
|
+
.boolean()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("Whether the uploaded file should be publicly readable. Defaults to the bucket's setting."),
|
|
56
|
+
},
|
|
57
|
+
}, async (args) => runTool(() => client.uploadFile({
|
|
58
|
+
projectId: args.projectId,
|
|
59
|
+
bucketId: args.bucketId,
|
|
60
|
+
filename: args.filename,
|
|
61
|
+
contentBase64: args.contentBase64,
|
|
62
|
+
mimeType: args.mimeType,
|
|
63
|
+
isPublic: args.isPublic,
|
|
64
|
+
})));
|
|
65
|
+
server.registerTool("mudbase_delete_file", {
|
|
66
|
+
title: "Delete a Mudbase file",
|
|
67
|
+
description: "Permanently delete a file from a Mudbase storage bucket. This cannot be undone.",
|
|
68
|
+
inputSchema: { projectId, bucketId, fileId },
|
|
69
|
+
annotations: { destructiveHint: true },
|
|
70
|
+
}, async (args) => runTool(() => client.deleteFile({ projectId: args.projectId, bucketId: args.bucketId, fileId: args.fileId })));
|
|
71
|
+
server.registerTool("mudbase_get_file_download_url", {
|
|
72
|
+
title: "Get a signed download URL for a Mudbase file",
|
|
73
|
+
description: "Generate a time-limited signed URL to download a private or public file from Mudbase storage.",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
projectId,
|
|
76
|
+
bucketId,
|
|
77
|
+
fileId,
|
|
78
|
+
expiresIn: z
|
|
79
|
+
.number()
|
|
80
|
+
.int()
|
|
81
|
+
.min(60)
|
|
82
|
+
.max(604_800)
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("How long the URL stays valid, in seconds. Defaults to 3600 (1 hour)."),
|
|
85
|
+
},
|
|
86
|
+
}, async (args) => runTool(() => client.getFileDownloadUrl({
|
|
87
|
+
projectId: args.projectId,
|
|
88
|
+
bucketId: args.bucketId,
|
|
89
|
+
fileId: args.fileId,
|
|
90
|
+
expiresIn: args.expiresIn,
|
|
91
|
+
})));
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/tools/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;AACxE,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC,CAAC;AACzF,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;AAE5E,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,MAAqB;IAC3E,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,8BAA8B;QACrC,WAAW,EAAE,2DAA2D;QACxE,WAAW,EAAE;YACX,SAAS;YACT,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8CA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E,CAAC;SACpF;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,OAAO,CAAC,GAAG,EAAE,CACX,MAAM,CAAC,kBAAkB,CAAC;QACxB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC,CACH,CACJ,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mudbase-mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server that exposes Mudbase's database, storage, and search capabilities as tools for Claude Code and other MCP clients, gated by a Mudbase API key.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Mudbase Team",
|
|
8
|
+
"homepage": "https://mudbase.dev",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/themudhaxk/mudbase-mcp-server.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/themudhaxk/mudbase-mcp-server/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mcp",
|
|
18
|
+
"model-context-protocol",
|
|
19
|
+
"mudbase",
|
|
20
|
+
"baas",
|
|
21
|
+
"claude",
|
|
22
|
+
"claude-code",
|
|
23
|
+
"database",
|
|
24
|
+
"storage"
|
|
25
|
+
],
|
|
26
|
+
"bin": {
|
|
27
|
+
"mudbase-mcp-server": "dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc -p tsconfig.json",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"start": "node dist/index.js",
|
|
43
|
+
"dev": "tsx src/index.ts",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"lint": "eslint src test --ext .ts"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
51
|
+
"axios": "^1.7.9",
|
|
52
|
+
"form-data": "^4.0.1",
|
|
53
|
+
"zod": "^3.24.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.10.5",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.19.1",
|
|
58
|
+
"@typescript-eslint/parser": "^8.19.1",
|
|
59
|
+
"eslint": "^8.57.1",
|
|
60
|
+
"tsx": "^4.19.2",
|
|
61
|
+
"typescript": "^5.7.3",
|
|
62
|
+
"vitest": "^3.2.7"
|
|
63
|
+
}
|
|
64
|
+
}
|