Working with Connectors
To utilize a connector within your MCP Server, you can declare them in the tool that you would like to utilze them in within the defineTool.
import { z } from "zod";import { defineTool, postgres, sql } from "@mcpexpress/core";
export const recentOrders = defineTool({ // Other declarations ... // "shop_database" is the connector's name on the Connectors page; `shop` is yours. connectors: { shop: postgres("shop_database") }, // Tool function with connectors provided during runtime execute: async ({ customerId }, { connectors }) => { const { rows } = await connectors.shop.query( sql`select id, status, total from orders where customer_id = ${customerId} order by created_at desc limit 10`, ); return { orders: rows }; },});The above example declares usage on the shop_database (configured within MCP Express, refer here). The tool call is provided with the connectors object which contains the dictionary of the connectors declared.