updateProfile
Modify your Nostr profile by updating display name, bio, picture, lightning address, or other details. Merges changes with existing profile data.
Instructions
Update an existing Nostr profile (merges with current)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Display name | |
| about | No | Bio / about text | |
| picture | No | Profile picture URL | |
| nip05 | No | NIP-05 identifier | |
| lud16 | No | Lightning address | |
| banner | No | Banner image URL | |
| website | No | Website URL | |
| privateKey | No | Private key (nsec or hex). Optional when NOSTR_BUNKER_URI is configured. | |
| relays | No | Relays to publish to |
Implementation Reference
- src/tools/profile-tools.ts:60-82 (handler)The implementation of the `updateProfile` handler, which fetches existing metadata to perform a merge before publishing.
export async function updateProfile(params: z.infer<typeof updateProfileSchema>) { const { privateKey, relays, ...newFields } = params; // Fetch existing profile to merge const pubkey = resolveSigningPubkey(privateKey); const existing = await queryEvent( { kinds: [KINDS.METADATA], authors: [pubkey], limit: 1 }, relays ?? DEFAULT_RELAYS, ); let mergedFields: Record<string, string | undefined> = {}; if (existing) { try { mergedFields = JSON.parse(existing.content); } catch {} } for (const [k, v] of Object.entries(newFields)) { if (v !== undefined) mergedFields[k] = v; } return buildAndPublishProfile(mergedFields, privateKey, relays); } - src/tools/profile-tools.ts:23-23 (schema)Definition of the Zod schema for the `updateProfile` tool input.
export const updateProfileSchema = createProfileSchema; - src/index.ts:93-95 (registration)Registration of the `updateProfile` tool in the MCP server.
server.tool('updateProfile', 'Update an existing Nostr profile (merges with current)', updateProfileSchema.shape, async (params) => { return textResult(await updateProfile(params)); });