Skip to main content
Glama
AaroYazilim

AARO ERP MCP Server

by AaroYazilim

erp_dekont_kalem_ekle

Add stock items to vouchers in the AARO ERP system by specifying voucher ID, stock ID, quantity, and amount to manage inventory transactions.

Instructions

Dekonta stok kalemi ekler

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
DekontIDYesDekont ID (zorunlu)
StokIDYesStok ID (zorunlu)
MiktarYesMiktar (zorunlu)
TutarYesTutar (zorunlu)
DovizIDNoDöviz ID (varsayılan: 1)
TutarDvzNoDövizli tutar (varsayılan: 0)
BANoBorç/Alacak (varsayılan: A)
DepoIDNoDepo ID (varsayılan: 1)
TeslimTarihiNoTeslim tarihi (YYYY-MM-DD)
VergiIDNoVergi ID (varsayılan: 1)
VergiOraniNoVergi oranı (varsayılan: 18)

Implementation Reference

  • Implements the core logic for the 'erp_dekont_kalem_ekle' tool by adding a new item (kalem) to an existing dekont (invoice) via the ERP API endpoint '/api/Dekont/Kalem'. Validates required parameters, constructs the request body, and calls the generic ERP API caller.
    private async addDekontKalem(args: any) {
      const { 
        DekontID, 
        StokID, 
        Miktar, 
        Tutar, 
        DovizID, 
        TutarDvz, 
        BA, 
        DepoID, 
        TeslimTarihi, 
        VergiID, 
        VergiOrani 
      } = args;
      
      if (!DekontID || !StokID || !Miktar || !Tutar) {
        throw new Error('DekontID, StokID, Miktar ve Tutar gerekli');
      }
    
      const kalemData = {
        KalemTipi: 7, // Sabit değer
        DekontID: parseInt(DekontID),
        KartID: parseInt(StokID),
        Miktar: parseFloat(Miktar),
        Tutar: parseFloat(Tutar),
        DovizID: parseInt(DovizID || '1'),
        TutarDvz: parseFloat(TutarDvz || '0'),
        BA: BA || 'A',
        SiparisStok: {
          DepoID: parseInt(DepoID || '1'),
          TeslimTarihi: TeslimTarihi || new Date().toISOString().split('T')[0],
          VergiDetaylari: [
            {
              VergiID: parseInt(VergiID || '1'),
              Oran: parseFloat(VergiOrani || '20'),
              Tutar: parseFloat(Tutar) * (parseFloat(VergiOrani || '20') / 100),
              TutarDvz: 0,
              DovizID: parseInt(DovizID || '1'),
              Matrah: parseFloat(Tutar),
              MatrahDvz: 0,
              BA: BA || 'A'
            }
          ]
        }
      };
    
      this.log('Dekont kalemi ekleniyor', 'info', kalemData);
    
      return await this.callErpApi('/api/Dekont/Kalem', 'POST', {
        KayitTipi: '1',
        body: kalemData
      });
    }
  • src/index.ts:244-245 (registration)
    Registers the 'addDekontKalem' special handler in the tool dispatch switch statement within callSpecialHandler method, which is invoked for tools configured with handler: 'addDekontKalem' in tools.json (likely mapping to tool name 'erp_dekont_kalem_ekle').
    case 'addDekontKalem':
      return await this.addDekontKalem(args);
  • Generic helper method used by addDekontKalem to perform authenticated API calls to the ERP system, handling token management, headers, and error handling.
    private async callErpApi(endpoint: string, method: 'GET' | 'POST', args: any) {
      try {
        // Token'ı otomatik olarak al (cache'den veya yeni)
        let token = this.getCachedToken();
        if (!token) {
          this.log('Token bulunamadı, yeni token alınıyor...');
          token = await this.getErpToken();
        }
        
        // URL'nin harici olup olmadığını kontrol et
        const isExternalUrl = endpoint.startsWith('http://') || endpoint.startsWith('https://');
        const finalUrl = isExternalUrl ? endpoint : `${this.settings.erp.baseUrl}${endpoint}`;
        
        const config: any = {
          method,
          url: finalUrl,
          headers: {
            'Authorization': `Bearer ${encodeURIComponent(token)}`,
            ...this.settings.api.defaultHeaders,
          },
          timeout: this.settings.api.timeout,
        };
    
        // Harici URL için ek header'lar ekle
        if (isExternalUrl) {
          config.headers['X-Original-ERP-URL'] = `${this.settings.erp.baseUrl}${endpoint.replace(/^https?:\/\/[^\/]+/, '')}`;
          config.headers['X-ERP-Token'] = encodeURIComponent(token);
        }
    
        if (method === 'GET') {
          // Tüm parametreleri query string olarak ekle
          const queryParams = { ...args };
          delete queryParams.endpoint;
          delete queryParams.method;
          delete queryParams.body;
          
          if (Object.keys(queryParams).length > 0) {
            config.params = queryParams;
          }
        } else if (method === 'POST') {
          if (args.body) {
            config.data = args.body;
          }
          
          // POST için query parametreleri de ekle
          const queryParams = { ...args };
          delete queryParams.endpoint;
          delete queryParams.method;
          delete queryParams.body;
          
          if (Object.keys(queryParams).length > 0) {
            config.params = queryParams;
          }
        }
    
        this.log(`API çağrısı: ${method} ${endpoint}`, 'info', {
          url: config.url,
          method: config.method,
          params: config.params,
          isExternal: isExternalUrl
        });
        
        const response = await axios(config);
        
        this.log(`API başarılı: ${method} ${endpoint}`, 'info', {
          status: response.status,
          dataLength: JSON.stringify(response.data).length,
          isExternal: isExternalUrl
        });
        
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2),
            },
          ],
        };
      } catch (error) {
        let errorMessage = 'Bilinmeyen hata';
        
        if (axios.isAxiosError(error)) {
          if (error.response) {
            errorMessage = `HTTP ${error.response.status}: ${error.response.statusText}`;
            if (error.response.data) {
              errorMessage += `\n${JSON.stringify(error.response.data, null, 2)}`;
            }
          } else if (error.request) {
            errorMessage = 'İstek gönderildi ancak yanıt alınamadı';
          } else {
            errorMessage = error.message;
          }
        } else if (error instanceof Error) {
          errorMessage = error.message;
        }
    
        this.log(`API hatası: ${method} ${endpoint}`, 'error', { error: errorMessage });
    
        return {
          content: [
            {
              type: 'text',
              text: `API Hatası: ${errorMessage}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:176-216 (registration)
    Dynamic tool registration and dispatching logic in setupToolHandlers: loads tools from config/tools.json, lists them via ListToolsRequestSchema, and dispatches to special handlers like 'addDekontKalem' based on tool config.
      this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
        const { name, arguments: args } = request.params;
    
        try {
          const toolConfig = this.toolsConfig[name];
          if (!toolConfig) {
            throw new McpError(ErrorCode.MethodNotFound, `Bilinmeyen araç: ${name}`);
          }
    
          // Request bilgilerini logla
          this.log(`Tool çağrısı: ${name}`, 'info', { 
            tool: name, 
            params: args 
          });
    
          // Özel handler varsa onu kullan
          if (toolConfig.handler) {
            return await this.callSpecialHandler(toolConfig.handler, args);
          }
    
          // Normal API çağrısı
          if (toolConfig.endpoint && toolConfig.method) {
            return await this.callErpApi(toolConfig.endpoint, toolConfig.method as 'GET' | 'POST', args);
          }
    
          throw new McpError(ErrorCode.InternalError, `Tool konfigürasyonu eksik: ${name}`);
    
        } catch (error) {
          this.log(`Tool hatası: ${name}`, 'error', error);
          return {
            content: [
              {
                type: 'text',
                text: `Hata: ${error instanceof Error ? error.message : 'Bilinmeyen hata'}`,
              },
            ],
            isError: true,
          };
        }
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Dekonta stok kalemi ekler' implies a write/mutation operation but doesn't disclose permissions needed, whether changes are reversible, rate limits, or what happens on success/failure. For a tool with 11 parameters and no annotation coverage, this is insufficient.

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 a single, efficient Turkish phrase that states the core purpose without unnecessary words. It's appropriately sized and front-loaded with the essential information.

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

Completeness2/5

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

For a complex write operation with 11 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after adding the stock item, what validation occurs, or what the tool returns. The context signals indicate significant complexity that the description doesn't address.

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

Parameters3/5

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

The description adds no parameter semantics beyond what's already in the schema (which has 100% coverage with detailed descriptions for all 11 parameters). The baseline is 3 since the schema does the heavy lifting, but the description doesn't provide additional context about parameter relationships or business logic.

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

Purpose4/5

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

The description 'Dekonta stok kalemi ekler' clearly states the action (ekler/adds) and the resource (stok kalemi/stock item to dekont/receipt). It's specific about what the tool does, though it doesn't explicitly differentiate from sibling tools like erp_dekont_duzenle or erp_dekont_olustur.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like erp_dekont_duzenle (edit receipt) and erp_dekont_olustur (create receipt), there's no indication of whether this tool is for adding items to existing receipts or when it should be preferred over other dekont-related tools.

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/AaroYazilim/aaro-erp-mcp-server'

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