updateProfile
Modify your Nostr profile by updating fields like display name, bio, profile picture, and contact information. 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 handler function for 'updateProfile' tool, which fetches the existing profile, merges it with the new fields, and publishes the updated profile.
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)The schema definition for 'updateProfile'. It reuses 'createProfileSchema'.
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)); });