/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { createSearchDocumentationTool } from './tools/search-documentation.js';
import { createReadDocumentationTool } from './tools/read-documentation.js';
import { getPackageVersion } from './utils.js';
import { generateDocumentationPathsDescription } from './constants.js';
export interface ServerConfig {
devAccountId: string;
}
// Create an MCP server with configuration
export function createServer(config: ServerConfig) {
const server = new McpServer(
{
name: 'ab-integrations-mcp-server',
version: getPackageVersion(),
},
{
capabilities: {
tools: {},
prompts: {},
},
instructions: `Amazon Business Integrations MCP Server
The Amazon Business Integrations MCP Server provides tool to access Amazon Business APIs documentation, search for content and solutions for common B2B integration usecases.
SITE MAP OF DOCUMENTATION:
${generateDocumentationPathsDescription()}
AVAILABLE TOOLS:
1. search-documentation - Perform semantic searches across the documentation corpus using natural language queries. Returns relevant documentation snippets with document references.
2. read-documentation - Retrieve relevant documentation content using document references obtained from search results.
HIGHLY RECOMMENDED: Start by reading the following documents (using read-documentation tool) when interacting with this server:
1. Getting started guide : "Guides and FAQs/amazon-business-apis-getting-started-guide.md"
2. To understand authentication requirements: "OAuth/oauth-instructions.md"
Note: When quering for code generation or building application, ALWAYS search for the swagger model, code snippets and any specific instructions given for generating code.
OAuth authentication must be implemented as a mandatory step for all Amazon Business API implementations. To understand common pitfalls, use read-documentation tool with reference "Guides and FAQs/common-pitfalls.md"`,
},
);
// Create tools with configuration
const searchDocumentationTool = createSearchDocumentationTool(config);
const readDocumentationTool = createReadDocumentationTool(config);
// @ts-ignore - Type checking bypassed to allow flexible implementation
server.tool(
searchDocumentationTool.name,
searchDocumentationTool.description,
searchDocumentationTool.paramSchema,
searchDocumentationTool.cb
);
// @ts-ignore - Type checking bypassed to allow flexible implementation
server.tool(
readDocumentationTool.name,
readDocumentationTool.description,
readDocumentationTool.paramSchema,
readDocumentationTool.cb
);
return server;
}