Skip to main content
Glama

send_message

Send messages to Duyet for collaboration, job opportunities, consulting, or general inquiries. Messages are saved with reference IDs for follow-up.

Instructions

Send a message to Duyet for collaboration, job opportunities, consulting, or general inquiries. Messages are saved with a reference ID for follow-up

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesMessage to send to Duyet (10-500 characters)
contact_emailNoOptional: Your email for response
purposeYesPurpose of your message

Implementation Reference

  • The asynchronous handler function for the 'send_message' tool. It performs rate limiting checks, inserts the message into the database using D1, handles errors, and returns structured success or error responses with reference ID.
    		async ({ message, contact_email, purpose }) => {
    			// Check rate limiting before processing
    			const rateLimitCheck = await checkRateLimit(db, contact_email, purpose);
    			if (!rateLimitCheck.allowed) {
    				return {
    					content: [
    						{
    							type: "text",
    							text: `Rate Limit Exceeded
    
    ${rateLimitCheck.reason}
    
    ${rateLimitCheck.retryAfter ? `You can try again in ${Math.ceil(rateLimitCheck.retryAfter / 60)} minutes.` : ""}
    
    Alternative: Email me directly at me@duyet.net`,
    						},
    					],
    					isError: true,
    				};
    			}
    
    			// Extract metadata - simplified for MCP context
    			const ip_address = "unknown";
    			const user_agent = "MCP Client";
    			const referenceId = crypto.randomUUID();
    
    			try {
    				await db.insert(contacts).values({
    					message,
    					contactEmail: contact_email,
    					purpose: purpose,
    					ipAddress: ip_address,
    					userAgent: user_agent,
    					referenceId,
    				});
    			} catch (_e: any) {
    				// Log error securely without exposing details
    				return {
    					content: [
    						{
    							type: "text",
    							text: "Your message was received but could not be saved to our system. Please try again or send your message directly via email at me@duyet.net.",
    						},
    					],
    				};
    			}
    
    			const timestamp = new Date().toLocaleString();
    
    			return {
    				content: [
    					{
    						type: "text",
    						text: `Message Sent Successfully
    
    Reference ID: ${referenceId}
    Message: ${message}
    ${contact_email ? `Your Email: ${contact_email}` : ""}
    Purpose: ${purpose.replace("_", " ")}
    Submitted: ${timestamp}
    
    How to reach Duyet:
    
    Email: me@duyet.net
    LinkedIn: https://linkedin.com/in/duyet
    GitHub: https://github.com/duyet
    
    Your message has been recorded for follow-up.
    
    ${purpose === "job_opportunity" ? "\nFor Job Opportunities: Please include details about the role, company, and tech stack. Remote positions preferred." : ""}
    ${purpose === "consulting" ? "\nFor Consulting: Please provide project scope, timeline, and technical requirements." : ""}`,
    					},
    				],
    			};
    		},
  • Zod schema definitions for input validation: message (10-500 chars string), contact_email (optional email), purpose (enum: collaboration, job_opportunity, consulting, general_inquiry).
    const messageSchema = z.string().min(10).max(500) as any;
    const contactEmailSchema = z.string().email().optional() as any;
    const purposeSchema = z.enum([
    	"collaboration",
    	"job_opportunity",
    	"consulting",
    	"general_inquiry",
    ]) as any;
  • server.registerTool call that registers the 'send_message' MCP tool, specifying title, description, inputSchema, and the handler function.
    	server.registerTool(
    		"send_message",
    		{
    			title: "Send Message to Duyet",
    			description:
    				"Send a message to Duyet for collaboration, job opportunities, consulting, or general inquiries. Messages are saved with a reference ID for follow-up",
    			inputSchema: {
    				message: messageSchema.describe("Message to send to Duyet (10-500 characters)"),
    				contact_email: contactEmailSchema.describe("Optional: Your email for response"),
    				purpose: purposeSchema.describe("Purpose of your message"),
    			},
    		},
    		async ({ message, contact_email, purpose }) => {
    			// Check rate limiting before processing
    			const rateLimitCheck = await checkRateLimit(db, contact_email, purpose);
    			if (!rateLimitCheck.allowed) {
    				return {
    					content: [
    						{
    							type: "text",
    							text: `Rate Limit Exceeded
    
    ${rateLimitCheck.reason}
    
    ${rateLimitCheck.retryAfter ? `You can try again in ${Math.ceil(rateLimitCheck.retryAfter / 60)} minutes.` : ""}
    
    Alternative: Email me directly at me@duyet.net`,
    						},
    					],
    					isError: true,
    				};
    			}
    
    			// Extract metadata - simplified for MCP context
    			const ip_address = "unknown";
    			const user_agent = "MCP Client";
    			const referenceId = crypto.randomUUID();
    
    			try {
    				await db.insert(contacts).values({
    					message,
    					contactEmail: contact_email,
    					purpose: purpose,
    					ipAddress: ip_address,
    					userAgent: user_agent,
    					referenceId,
    				});
    			} catch (_e: any) {
    				// Log error securely without exposing details
    				return {
    					content: [
    						{
    							type: "text",
    							text: "Your message was received but could not be saved to our system. Please try again or send your message directly via email at me@duyet.net.",
    						},
    					],
    				};
    			}
    
    			const timestamp = new Date().toLocaleString();
    
    			return {
    				content: [
    					{
    						type: "text",
    						text: `Message Sent Successfully
    
    Reference ID: ${referenceId}
    Message: ${message}
    ${contact_email ? `Your Email: ${contact_email}` : ""}
    Purpose: ${purpose.replace("_", " ")}
    Submitted: ${timestamp}
    
    How to reach Duyet:
    
    Email: me@duyet.net
    LinkedIn: https://linkedin.com/in/duyet
    GitHub: https://github.com/duyet
    
    Your message has been recorded for follow-up.
    
    ${purpose === "job_opportunity" ? "\nFor Job Opportunities: Please include details about the role, company, and tech stack. Remote positions preferred." : ""}
    ${purpose === "consulting" ? "\nFor Consulting: Please provide project scope, timeline, and technical requirements." : ""}`,
    					},
    				],
    			};
    		},
    	);
  • Call to registerSendMessageTool(server, env) as part of registering all interaction tools, followed by logging.
    registerSendMessageTool(server, env);
    logger.tool("send_message", "registered");

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/duyet/duyet-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server