version mise à jour par claude , à tester

This commit is contained in:
Arthur Ria
2026-05-20 09:38:07 +02:00
commit b59cbb3546
58 changed files with 24548 additions and 0 deletions
+266
View File
@@ -0,0 +1,266 @@
/**
* API Resources
* Provides catalog of WMS APIs available
*/
function listResources() {
return [
{
uri: 'api://catalog',
name: 'API Catalog',
description: 'Catalog of WMS APIs available with parameters and documentation',
mimeType: 'text/markdown',
},
];
}
async function readResource(uri) {
let content;
switch (uri) {
case 'api://catalog':
content = getAPICatalog();
break;
default:
throw new Error(`Unknown API resource: ${uri}`);
}
return {
contents: [{
uri,
mimeType: 'text/markdown',
text: content,
}],
};
}
function getAPICatalog() {
return `# WMS API Catalog
## Overview
The WMS provides several REST APIs for querying and modifying data.
**Base URL:** \`${process.env.WMS_API_BASE_URL || 'https://10.255.255.2/ApplicationService/api'}\`
**Authentication:** OAuth 2.0 Bearer Token (automatic)
---
## Query API
Execute LINQ queries against WMS entities.
**Endpoint:** \`/api/QueryExecute\`
**Method:** POST
**Authentication:** Required
### Request Format
\`\`\`json
{
"Application": "EasyWMS",
"QueryType": 1,
"Expression": "Context.{EntityType}.Select(z => z)"
}
\`\`\`
### Supported Entity Types
| Entity Type | Description |
|-------------|-------------|
| Products | Product references and SKUs |
| Containers | Pallets, boxes, and container types |
| Stocks | Available inventory by location |
| ProductLocations | Product placement in warehouse |
| Tasks | WMS tasks (picks, puts, moves, etc.) |
| Accounts | Customer accounts |
| Suppliers | Supplier information |
| Kits | Product kits and bundles |
| Aliases | Product aliases and alternative codes |
| InboundOrders | Inbound/receiving orders |
| Receptions | Actual receptions |
| OutboundOrders | Outbound/shipping orders |
### Example Queries
\`\`\`
# Get all products (limited)
Context.Products.Take(100).Select(z => z)
# Get specific fields
Context.Products.Select(z => new { z.Id, z.Code, z.Name })
# Filter and select
Context.Tasks.Where(z => z.Status == "Pending").Take(50).Select(z => z)
\`\`\`
### MCP Tool
Use \`call_query_api\` tool to execute queries.
---
## Command API
Execute commands to modify WMS data.
**Endpoint:** \`/api/CommandExecute\`
**Method:** POST
**Authentication:** Required
### Request Format
\`\`\`json
[
{
"Name": "CommandName, Mecalux.ITSW.EasyWMS.Modules.Contracts",
"Properties": {
"PropertyName": "value"
}
}
]
\`\`\`
### Common Commands
| Command | Description |
|---------|-------------|
| ProductRemoveCommand | Remove a product |
| ProductUpdateCommand | Update product information |
| ContainerCreateCommand | Create a new container |
| TaskCancelCommand | Cancel a task |
| InboundOrderCancelCommandV2 | Cancel an inbound order |
| OutboundOrderCancelCommand | Cancel an outbound order |
### Example Command
\`\`\`json
[
{
"Name": "Mecalux.ITSW.EasyWMS.Modules.MasterData.Contracts.Commands.ProductRemoveCommand, Mecalux.ITSW.EasyWMS.Modules.Contracts",
"Properties": {
"Id": "product-guid-here"
}
}
]
\`\`\`
### MCP Tool
Use \`execute_command\` tool to execute commands.
**⚠️ WARNING:** Commands modify data. Use with caution.
---
## Workflow API
Retrieve workflow definitions by application.
**Endpoint:** \`/AD/api/Workflow/GetByApplication\`
**Method:** POST
**Authentication:** Required
### Request Format
\`\`\`json
["EasyWMS", "AD", 5000, 0]
\`\`\`
Parameters:
1. Application name (e.g., "EasyWMS")
2. Tenant code (e.g., "AD")
3. Page size (e.g., 5000)
4. Offset (e.g., 0 for first page)
### Response
Array of workflow objects with:
- Id, Code, Name
- Category, Description
- Version, Status
- Created, Modified
- Definition (JSON)
### MCP Tools
Use workflow tools to interact with workflows:
- \`search_workflows\` - Search by name, code, description
- \`get_workflow_details\` - Get full workflow definition
- \`list_workflow_categories\` - List all categories
---
## Authentication
All APIs use OAuth 2.0 authentication.
**Token Endpoint:** \`/EasySTS/OAuth/Token\`
**Grant Types:** password, refresh_token
### Token Management
- Tokens expire after ~1200 seconds
- Automatic refresh when < 1000 seconds remaining
- Credentials configured in .env file
The MCP server handles authentication automatically.
---
## Error Handling
### HTTP Status Codes
- \`200\` - Success
- \`400\` - Bad request (invalid query/command)
- \`401\` - Unauthorized (token expired or invalid)
- \`403\` - Forbidden (insufficient permissions)
- \`500\` - Internal server error
### Error Response Format
\`\`\`json
{
"error": "Error message",
"details": "Detailed error information"
}
\`\`\`
---
## Rate Limits and Constraints
- **Query Limit:** Maximum 1000 rows per query (configurable)
- **Query Timeout:** 30 seconds (configurable)
- **Workflow Cache:** 1 hour TTL (configurable)
---
## Configuration
API settings are configured via environment variables:
\`\`\`env
WMS_API_BASE_URL=https://10.255.255.2/ApplicationService/api
WMS_API_TOKEN_URL=https://10.255.255.2/EasySTS/OAuth/Token
WMS_API_TENANT=AD
WMS_API_USERNAME=your-username
WMS_API_PASSWORD=your-password
WORKFLOW_API_BASE=https://10.255.255.2/AD/api
WORKFLOW_PAGE_SIZE=5000
MAX_QUERY_ROWS=1000
QUERY_TIMEOUT=30000
\`\`\`
---
**Note:** Use MCP tools to interact with these APIs. Direct API calls require proper authentication handling.
`;
}
module.exports = {
listResources,
readResource,
};