File tree Expand file tree Collapse file tree
packages/plugin-mcp/src/endpoints Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import crypto from 'crypto'
2- import { type PayloadHandler , UnauthorizedError , type Where } from 'payload'
2+ import { type PayloadHandler , type TypedUser , UnauthorizedError , type Where } from 'payload'
33
44import type { MCPAccessSettings , PluginMCPServerConfig } from '../types.js'
55
@@ -57,6 +57,14 @@ export const initializeMCPHandler = (pluginOptions: PluginMCPServerConfig) => {
5757 payload . logger . info ( '[payload-mcp] API Key is valid' )
5858 }
5959
60+ const user = docs [ 0 ] ?. user as TypedUser
61+ const customUserCollection =
62+ typeof pluginOptions . userCollection === 'string'
63+ ? pluginOptions . userCollection
64+ : pluginOptions . userCollection ?. slug
65+ user . collection = customUserCollection ?? 'users'
66+ user . _strategy = 'mcp-api-key' as const
67+
6068 return docs [ 0 ] as unknown as MCPAccessSettings
6169 }
6270
You can’t perform that action at this time.
0 commit comments