Skip to main content
Glama
AaroYazilim

AARO ERP MCP Server

by AaroYazilim

erp_dekont_olustur

Create new document headers in the ERP system for orders, quotes, invoices, and returns with required fields like document type, date, number, and customer ID.

Instructions

ERP sisteminde yeni dekont başlığı oluşturur (Sipariş, Teklif, Fatura vb.). Görüntülemek için: https://erp.aaro.com.tr/Fatura/Kalem?id={DekontID}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
TipIDYesDekont tipi (10013: Alınan Sipariş, 10014: Verilen Sipariş, 10015: Alınan Teklif, 10016: Verilen Teklif, 10005: Satış Faturası, 10006: Alış Faturası, 10007: Satış İade Faturası, 10008: Alış İade Faturası)
TarihYesDekont tarihi (YYYY-MM-DD)
BelgeNoYesBelge numarası aynı tipte bulunan id ye göre en son eklenen dekontu bul ve onun belgenosuna +1 ekle
VadeNoVade tarihi (YYYY-MM-DD)
SirketIDNoŞirket ID (varsayılan: 1)
SubeIDNoŞube ID (varsayılan: 1)
RefDepoIDNoReferans depo ID (varsayılan: 1)
CariIDYesCari ID (zorunlu)
DovizIDNoDöviz ID (varsayılan: 1)
AciklamaNoAçıklama

Implementation Reference

  • The handler function 'createDekont' that executes the core logic for creating a new Dekont (accounting voucher/invoice). This is likely the implementation for the 'erp_dekont_olustur' tool, as it matches the Turkish naming ('olustur' = create) and makes a POST request to /api/Dekont/Baslik to create the dekont header with a single cari (customer) item.
    private async createDekont(args: any) {
      const { TipID, Tarih, BelgeNo, Vade, SirketID, SubeID, RefDepoID, CariID, DovizID, Aciklama } = args;
      
      if (!TipID || !Tarih || !BelgeNo || !CariID) {
        throw new Error('TipID, Tarih, BelgeNo ve CariID gerekli');
      }
    
      const dekontData = {
        Baslik: {
          Tarih,
          BelgeNo,
          Vade: Vade || Tarih,
          TipID: parseInt(TipID),
          SirketID: parseInt(SirketID || '1'),
          SubeID: parseInt(SubeID || '1'),
          RefDepoID: parseInt(RefDepoID || '1')
        },
        KalemTek: {
          KalemTipi: 4, // Cari olduğunu gösterir
          KartID: parseInt(CariID),
          DovizID: parseInt(DovizID || '1'),
          Aciklama: Aciklama || ''
        }
      };
    
      this.log('Dekont oluşturuluyor', 'info', dekontData);
    
      return await this.callErpApi('/api/Dekont/Baslik', 'POST', {
        KayitTipi: '1',
        body: dekontData
      });
    }
  • src/index.ts:241-242 (registration)
    The switch case in callSpecialHandler that registers and routes calls to the 'createDekont' handler when a tool configured with handler: 'createDekont' is invoked. The tool name 'erp_dekont_olustur' is likely defined in config/tools.json mapping to this handler.
    case 'createDekont':
      return await this.createDekont(args);
  • Supporting utility function used by createDekont to make the actual ERP API call to /api/Dekont/Baslik. Manages authentication token (cached or fresh), constructs request, sends via axios, and formats response.
    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,
        };
      }
    }
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. It states this creates new document headers, implying a write/mutation operation, but doesn't disclose important behavioral traits: whether this requires specific permissions, what happens on success/failure, if the creation is reversible, rate limits, or authentication needs. The URL mention is helpful for post-creation viewing but doesn't cover core behavioral aspects.

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

Conciseness4/5

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

The description is appropriately concise with two sentences. The first sentence clearly states the purpose, and the second provides useful post-creation context (viewing URL). There's no wasted verbiage, and the information is front-loaded with the core purpose stated first.

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?

Given this is a creation/mutation tool with 10 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what happens after creation, what the tool returns, error conditions, or important behavioral constraints. The URL for viewing is helpful but doesn't compensate for the lack of output information and behavioral context needed for a mutation tool.

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?

Schema description coverage is 100%, so the schema already documents all 10 parameters thoroughly with descriptions, required status, and defaults. The description adds no parameter information beyond what's in the schema. According to guidelines, when schema coverage is high (>80%), the baseline is 3 even with no param info in description.

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 clearly states the tool's purpose: 'ERP sisteminde yeni dekont başlığı oluşturur (Sipariş, Teklif, Fatura vb.)' which translates to 'creates a new document header in the ERP system (Order, Quote, Invoice, etc.)'. This specifies the verb ('oluşturur' - creates) and resource ('dekont başlığı' - document header) with examples. It distinguishes from siblings like erp_dekont_listele (list) and erp_dekont_duzenle (edit), but doesn't explicitly contrast them.

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. While it mentions a URL for viewing created documents ('Görüntülemek için...'), this is post-creation information, not usage guidance. There's no mention of prerequisites, when to choose this over erp_dekont_duzenle (edit), or any context about the creation workflow.

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