fixed issue: when listing: (collections, attributes, indexes, users, buckets, files, teams) is only listed the first 25 items, now it lists up to 5000, listing documents was not affected because it already used pagination

This commit is contained in:
2025-11-01 21:24:16 +03:00
parent a2926293df
commit 6dcf8aa0ff

View File

@@ -653,7 +653,7 @@ class AppwriteMCPServer {
};
case "list":
const collections = await this.databases.listCollections(databaseId);
const collections = await this.databases.listCollections(databaseId, [Query.limit(5000)]);
const colList = collections.collections.map(col => `- ${col.name} (${col.$id})`).join('\n');
return {
content: [{ type: "text", text: `Collections in database ${databaseId} (${collections.total}):\n${colList}` }]
@@ -754,7 +754,7 @@ class AppwriteMCPServer {
};
case "list":
const attributesList = await this.databases.listAttributes(databaseId, collectionId);
const attributesList = await this.databases.listAttributes(databaseId, collectionId, [Query.limit(5000)]);
const attrList = attributesList.attributes.map((attr: any) => `- ${attr.key} (${attr.type})`).join('\n');
return {
content: [{ type: "text", text: `Attributes in collection ${collectionId} (${attributesList.total}):\n${attrList}` }]
@@ -884,7 +884,7 @@ class AppwriteMCPServer {
};
case "list":
const indexes = await this.databases.listIndexes(databaseId, collectionId);
const indexes = await this.databases.listIndexes(databaseId, collectionId, [Query.limit(5000)]);
const indexList = indexes.indexes.map(idx => `- ${idx.key} (${idx.type}) - [${idx.attributes.join(', ')}]`).join('\n');
return {
content: [{ type: "text", text: `Indexes in collection ${collectionId} (${indexes.total}):\n${indexList}` }]
@@ -1137,8 +1137,24 @@ class AppwriteMCPServer {
case "get":
if (!userId) throw new Error("userId is required for get action");
const getUser = await this.users.get(userId);
let userDetails = `User Details:\n- ID: ${getUser.$id}\n- Email: ${getUser.email}\n- Name: ${getUser.name || 'N/A'}\n- Status: ${getUser.status}\n- Registration: ${getUser.registration}`;
// Add phone if available
if (getUser.phone) userDetails += `\n- Phone: ${getUser.phone}`;
// Add labels if available
if (getUser.labels && getUser.labels.length > 0) {
userDetails += `\n- Labels: ${getUser.labels.join(', ')}`;
}
// Add preferences if available
if (getUser.prefs && Object.keys(getUser.prefs).length > 0) {
userDetails += `\n- Preferences: ${JSON.stringify(getUser.prefs, null, 2)}`;
}
return {
content: [{ type: "text", text: `User Details:\n- ID: ${getUser.$id}\n- Email: ${getUser.email}\n- Name: ${getUser.name || 'N/A'}\n- Status: ${getUser.status}\n- Registration: ${getUser.registration}` }]
content: [{ type: "text", text: userDetails }]
};
case "update":
@@ -1236,10 +1252,24 @@ class AppwriteMCPServer {
private async listUsers(args: any) {
if (!this.users) throw new Error("Users not initialized");
const { queries, limit, offset } = args;
const users = await this.users.list();
const parsedQueries: string[] = [];
if (queries && Array.isArray(queries)) {
for (const queryStr of queries) {
parsedQueries.push(this.parseQuery(queryStr));
}
}
if (limit) parsedQueries.push(Query.limit(limit));
if (offset) parsedQueries.push(Query.offset(offset));
// If no limit specified, default to 5000 to get all users
if (!limit && !queries) parsedQueries.push(Query.limit(5000));
const users = await this.users.list(parsedQueries);
const userList = users.users.map(user => `- ${user.email} (${user.$id}) - ${user.status}`).join('\n');
return {
content: [{ type: "text", text: `Users (${users.total}):\n${userList}` }]
@@ -1267,7 +1297,7 @@ class AppwriteMCPServer {
};
case "list":
const buckets = await this.storage.listBuckets();
const buckets = await this.storage.listBuckets([Query.limit(5000)]);
const bucketList = buckets.buckets.map(bucket => `- ${bucket.name} (${bucket.$id}) - ${bucket.enabled ? 'enabled' : 'disabled'}`).join('\n');
return {
content: [{ type: "text", text: `Storage Buckets (${buckets.total}):\n${bucketList}` }]
@@ -1331,7 +1361,7 @@ class AppwriteMCPServer {
};
case "list":
const files = await this.storage.listFiles(bucketId);
const files = await this.storage.listFiles(bucketId, [Query.limit(5000)]);
const fileList = files.files.map(file => `- ${file.name} (${file.$id}) - ${file.sizeOriginal} bytes`).join('\n');
return {
content: [{ type: "text", text: `Files in bucket ${bucketId} (${files.total}):\n${fileList}` }]
@@ -1392,7 +1422,7 @@ class AppwriteMCPServer {
};
case "list":
const teams = await this.teams.list();
const teams = await this.teams.list([Query.limit(5000)]);
const teamList = teams.teams.map(team => `- ${team.name} (${team.$id}) - ${team.total} members`).join('\n');
return {
content: [{ type: "text", text: `Teams (${teams.total}):\n${teamList}` }]