Skip to main content
Glama

Create Shipment

create_shipment

Create a UPS shipment and generate a shipping label with tracking number and charges for domestic and international services.

Instructions

Create a UPS shipment and generate a shipping label. Supports all UPS domestic and international services. Returns tracking number, charges, and label image (base64-encoded GIF by default). Common service codes: 03=Ground, 02=2nd Day Air, 01=Next Day Air, 13=Next Day Air Saver, 12=3 Day Select, 07=Express (intl), 11=Standard (intl).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceNoUPS service code (e.g. "03" for Ground, "01" for Next Day Air)03
shipFromYesOrigin/sender address
shipToYesDestination/recipient address
packagesYesArray of packages (1-200)
descriptionNoShipment description
referenceNumberNoYour reference number for this shipment
labelFormatNoLabel image formatGIF

Implementation Reference

  • Tool registration entry point - addShippingTools function that registers 'create_shipment' with the MCP server
    export function addShippingTools(server: McpServer, client: UPSHttpClient): void {
    	server.registerTool(
    		'create_shipment',
    		{
    			title: 'Create Shipment',
    			description:
    				'Create a UPS shipment and generate a shipping label. Supports all UPS domestic and international services. Returns tracking number, charges, and label image (base64-encoded GIF by default). Common service codes: 03=Ground, 02=2nd Day Air, 01=Next Day Air, 13=Next Day Air Saver, 12=3 Day Select, 07=Express (intl), 11=Standard (intl).',
    			inputSchema: {
    				service: z
    					.string()
    					.default('03')
    					.describe('UPS service code (e.g. "03" for Ground, "01" for Next Day Air)'),
    				shipFrom: fullAddressSchema.describe('Origin/sender address'),
    				shipTo: fullAddressSchema.describe('Destination/recipient address'),
    				packages: z
    					.array(shippingPackageSchema)
    					.min(1)
    					.max(SHIPMENT_LIMITS.MAX_PACKAGES)
    					.describe('Array of packages (1-200)'),
    				description: z.string().optional().describe('Shipment description'),
    				referenceNumber: z.string().optional().describe('Your reference number for this shipment'),
    				labelFormat: z
    					.enum(['GIF', 'EPL', 'ZPL', 'SPL', 'STARPL'])
    					.default('GIF')
    					.describe('Label image format'),
    			},
    		},
    		async ({ service, shipFrom, shipTo, packages, description, referenceNumber, labelFormat }) => {
    			const accountNumber = client.getAccountNumber();
    			const shipFromAddress = buildUPSAddress(shipFrom);
    			const shipToAddress = buildUPSAddress(shipTo);
    
    			const shipmentRequest = {
    				ShipmentRequest: {
    					Request: {
    						SubVersion: API_VERSIONS.SHIPPING,
    						RequestOption: SHIPMENT_REQUEST_OPTIONS.NON_VALIDATE,
    						TransactionReference: { CustomerContext: referenceNumber ?? '' },
    					},
    					Shipment: {
    						Description: description ?? '',
    						Shipper: { ...shipFromAddress, ShipperNumber: accountNumber ?? '' },
    						ShipTo: shipToAddress,
    						ShipFrom: shipFromAddress,
    						PaymentInformation: {
    							ShipmentCharge: [
    								{
    									Type: CHARGE_TYPES.TRANSPORTATION,
    									BillShipper: { AccountNumber: accountNumber ?? '' },
    								},
    							],
    						},
    						Service: { Code: service, Description: '' },
    						Package: packages.map((pkg) => ({
    							Packaging: { Code: pkg.packaging ?? '02', Description: '' },
    							Dimensions: pkg.length
    								? buildDimensions(pkg.length, pkg.width, pkg.height)
    								: undefined,
    							PackageWeight: buildWeight(pkg.weight),
    							Description: pkg.description ?? '',
    							...(pkg.insuredValue
    								? {
    										PackageServiceOptions: {
    											DeclaredValue: {
    												CurrencyCode: 'USD',
    												MonetaryValue: String(pkg.insuredValue),
    											},
    										},
    									}
    								: {}),
    						})),
    						...(referenceNumber
    							? {
    									ReferenceNumber: {
    										Code: REFERENCE_TYPES.PURCHASE_ORDER,
    										Value: referenceNumber,
    									},
    								}
    							: {}),
    					},
    					LabelSpecification: {
    						LabelImageFormat: { Code: labelFormat, Description: '' },
    						LabelStockSize: { Height: LABEL_STOCK.HEIGHT, Width: LABEL_STOCK.WIDTH },
    					},
    				},
    			};
    
    			const response = await client.post<unknown>(
    				`/api/shipments/${API_VERSIONS.SHIPPING}/ship`,
    				shipmentRequest,
    			);
    
    			return formatToolResponse(response);
    		},
    	);
  • Handler function that executes the create_shipment logic: builds the UPS ShipmentRequest, calls the API endpoint, and returns formatted response
    async ({ service, shipFrom, shipTo, packages, description, referenceNumber, labelFormat }) => {
    	const accountNumber = client.getAccountNumber();
    	const shipFromAddress = buildUPSAddress(shipFrom);
    	const shipToAddress = buildUPSAddress(shipTo);
    
    	const shipmentRequest = {
    		ShipmentRequest: {
    			Request: {
    				SubVersion: API_VERSIONS.SHIPPING,
    				RequestOption: SHIPMENT_REQUEST_OPTIONS.NON_VALIDATE,
    				TransactionReference: { CustomerContext: referenceNumber ?? '' },
    			},
    			Shipment: {
    				Description: description ?? '',
    				Shipper: { ...shipFromAddress, ShipperNumber: accountNumber ?? '' },
    				ShipTo: shipToAddress,
    				ShipFrom: shipFromAddress,
    				PaymentInformation: {
    					ShipmentCharge: [
    						{
    							Type: CHARGE_TYPES.TRANSPORTATION,
    							BillShipper: { AccountNumber: accountNumber ?? '' },
    						},
    					],
    				},
    				Service: { Code: service, Description: '' },
    				Package: packages.map((pkg) => ({
    					Packaging: { Code: pkg.packaging ?? '02', Description: '' },
    					Dimensions: pkg.length
    						? buildDimensions(pkg.length, pkg.width, pkg.height)
    						: undefined,
    					PackageWeight: buildWeight(pkg.weight),
    					Description: pkg.description ?? '',
    					...(pkg.insuredValue
    						? {
    								PackageServiceOptions: {
    									DeclaredValue: {
    										CurrencyCode: 'USD',
    										MonetaryValue: String(pkg.insuredValue),
    									},
    								},
    							}
    						: {}),
    				})),
    				...(referenceNumber
    					? {
    							ReferenceNumber: {
    								Code: REFERENCE_TYPES.PURCHASE_ORDER,
    								Value: referenceNumber,
    							},
    						}
    					: {}),
    			},
    			LabelSpecification: {
    				LabelImageFormat: { Code: labelFormat, Description: '' },
    				LabelStockSize: { Height: LABEL_STOCK.HEIGHT, Width: LABEL_STOCK.WIDTH },
    			},
    		},
    	};
    
    	const response = await client.post<unknown>(
    		`/api/shipments/${API_VERSIONS.SHIPPING}/ship`,
    		shipmentRequest,
    	);
    
    	return formatToolResponse(response);
    },
  • Input schema for create_shipment tool: defines service, shipFrom, shipTo, packages, description, referenceNumber, labelFormat with Zod validation
    	inputSchema: {
    		service: z
    			.string()
    			.default('03')
    			.describe('UPS service code (e.g. "03" for Ground, "01" for Next Day Air)'),
    		shipFrom: fullAddressSchema.describe('Origin/sender address'),
    		shipTo: fullAddressSchema.describe('Destination/recipient address'),
    		packages: z
    			.array(shippingPackageSchema)
    			.min(1)
    			.max(SHIPMENT_LIMITS.MAX_PACKAGES)
    			.describe('Array of packages (1-200)'),
    		description: z.string().optional().describe('Shipment description'),
    		referenceNumber: z.string().optional().describe('Your reference number for this shipment'),
    		labelFormat: z
    			.enum(['GIF', 'EPL', 'ZPL', 'SPL', 'STARPL'])
    			.default('GIF')
    			.describe('Label image format'),
    	},
    },
  • TypeScript interface CreateShipmentParams defining all parameters for creating a shipment
    export interface CreateShipmentParams {
    	readonly service: UPSServiceCode;
    	readonly shipFrom: UPSAddress;
    	readonly shipTo: UPSAddress;
    	readonly packages: readonly ShipmentPackage[];
    	readonly description?: string;
    	readonly referenceNumber?: string;
    	readonly labelFormat?: LabelFormat;
    	readonly returnService?: ReturnServiceCode;
    	readonly paymentInformation?: PaymentInformation;
    	readonly shipmentServiceOptions?: ShipmentServiceOptions;
    	readonly documentsOnly?: boolean;
    }
  • Helper that wraps API response into MCP tool output format with JSON text content
    export function formatToolResponse(response: unknown) {
    	return {
    		content: [{ type: 'text' as const, text: JSON.stringify(response, null, 2) }],
    	};
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description must carry the burden. It discloses that it creates a shipment and returns data, but does not mention that it actually books the shipment (which incurs costs) or any prerequisites like having a valid UPS account.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, front-loaded with the core purpose, and includes only relevant additional details (service codes, return data) without superfluous text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of nested objects and no output schema, the description covers the key return values (tracking number, charges, label) and service codes. Missing are prerequisites or error handling, but overall it is fairly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already explains each parameter well. The description adds value by listing common service codes with their meanings and indicating the default label format (GIF).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Create a UPS shipment and generate a shipping label' and lists what it returns (tracking number, charges, label image), distinguishing it from sibling tools like get_rates or track_package.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage through its purpose and service code list, but does not explicitly explain when to use it over alternatives like get_rates for cost estimation or schedule_pickup for pickup needs.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/roscoej/ups-mcp'

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