edition-mcp-server 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +98 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -764,6 +764,104 @@ else {
764
764
  }
765
765
  });
766
766
  } // end of legacy mode else block
767
+ const auditLog = [];
768
+ let auditCounter = 0;
769
+ function recordAudit(entry) {
770
+ const record = {
771
+ id: `AUDIT-${++auditCounter}-${Date.now()}`,
772
+ timestamp: new Date().toISOString(),
773
+ ...entry,
774
+ };
775
+ auditLog.push(record);
776
+ return record;
777
+ }
778
+ // Tool: compliance_log — Record a compliance check with audit trail
779
+ server.tool("compliance_log", "Record a Japan regulatory/compliance check with full audit trail. Use this AFTER performing a regulation_check, foreign_entry_check, or any compliance-sensitive query. Creates an immutable, timestamped record for governance reporting. Agents operating under compliance requirements should call this after every regulatory lookup.", {
780
+ domain: zod_1.z.string().describe("Knowledge domain checked (e.g. 'regulation', 'foreign_entry', 'protocol')"),
781
+ action: zod_1.z.string().describe("Action that was checked (e.g. 'open restaurant in Tokyo', 'apply for management visa')"),
782
+ query: zod_1.z.string().describe("The original query/action that triggered the compliance check"),
783
+ result_summary: zod_1.z.string().describe("Summary of the compliance check result"),
784
+ confidence: zod_1.z.number().min(0).max(1).describe("Confidence score of the check (0-1)"),
785
+ compliant: zod_1.z.boolean().describe("Whether the action was found to be compliant"),
786
+ context: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional().describe("Additional context (industry, entity_type, jurisdiction, etc.)"),
787
+ }, { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, async ({ domain, action, query, result_summary, confidence, compliant, context }) => {
788
+ const record = recordAudit({
789
+ domain,
790
+ action,
791
+ query,
792
+ result_summary,
793
+ confidence,
794
+ compliant,
795
+ metadata: {
796
+ ...context,
797
+ server_version: "0.3.1",
798
+ mode: PROGRESSIVE ? "progressive" : "legacy",
799
+ },
800
+ });
801
+ let text = `šŸ“‹ Compliance Audit Record Created\n`;
802
+ text += `━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
803
+ text += ` ID: ${record.id}\n`;
804
+ text += ` Timestamp: ${record.timestamp}\n`;
805
+ text += ` Domain: ${record.domain}\n`;
806
+ text += ` Action: ${record.action}\n`;
807
+ text += ` Status: ${record.compliant ? "āœ… COMPLIANT" : "āš ļø NON-COMPLIANT / REQUIRES REVIEW"}\n`;
808
+ text += ` Confidence: ${(record.confidence * 100).toFixed(0)}%\n`;
809
+ text += ` Summary: ${record.result_summary}\n`;
810
+ text += `━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`;
811
+ text += `\nTotal audit records this session: ${auditLog.length}`;
812
+ return { content: [{ type: "text", text }] };
813
+ });
814
+ // Tool: compliance_report — Generate governance report from audit trail
815
+ server.tool("compliance_report", "Generate a structured compliance/governance report from accumulated audit records. Returns all logged compliance checks with statistics. Use for periodic compliance reviews, audit preparation, or governance dashboards. Supports filtering by domain, date range, or compliance status.", {
816
+ domain: zod_1.z.string().optional().describe("Filter by domain (e.g. 'regulation'). Omit for all domains."),
817
+ compliant_only: zod_1.z.boolean().optional().describe("If true, show only compliant records. If false, show only non-compliant. Omit for all."),
818
+ format: zod_1.z.enum(["summary", "detailed", "json"]).default("summary").describe("Report format: summary (overview + stats), detailed (all records), json (machine-readable)"),
819
+ }, { readOnlyHint: true, destructiveHint: false, idempotentHint: true }, async ({ domain, compliant_only, format }) => {
820
+ let records = [...auditLog];
821
+ if (domain)
822
+ records = records.filter(r => r.domain === domain);
823
+ if (compliant_only !== undefined)
824
+ records = records.filter(r => r.compliant === compliant_only);
825
+ if (records.length === 0) {
826
+ return { content: [{ type: "text", text: "šŸ“Š No compliance records found for the specified criteria.\n\nšŸ’” Use compliance_log after regulatory checks to build your audit trail." }] };
827
+ }
828
+ if (format === "json") {
829
+ return { content: [{ type: "text", text: JSON.stringify({ total: records.length, records }, null, 2) }] };
830
+ }
831
+ // Statistics
832
+ const total = records.length;
833
+ const compliant = records.filter(r => r.compliant).length;
834
+ const nonCompliant = total - compliant;
835
+ const avgConfidence = records.reduce((sum, r) => sum + r.confidence, 0) / total;
836
+ const domains = [...new Set(records.map(r => r.domain))];
837
+ const timeRange = records.length > 0
838
+ ? `${records[0].timestamp} → ${records[records.length - 1].timestamp}`
839
+ : "N/A";
840
+ let text = `\nšŸ“Š EDITION Compliance Governance Report\n`;
841
+ text += `══════════════════════════════════════\n\n`;
842
+ text += `šŸ“… Period: ${timeRange}\n`;
843
+ text += `šŸ“ˆ Total Checks: ${total}\n`;
844
+ text += ` āœ… Compliant: ${compliant} (${((compliant / total) * 100).toFixed(1)}%)\n`;
845
+ text += ` āš ļø Review Needed: ${nonCompliant} (${((nonCompliant / total) * 100).toFixed(1)}%)\n`;
846
+ text += ` šŸ“Š Average Confidence: ${(avgConfidence * 100).toFixed(1)}%\n`;
847
+ text += ` šŸ—‚ļø Domains Covered: ${domains.join(", ")}\n`;
848
+ text += `\n══════════════════════════════════════\n`;
849
+ if (format === "detailed") {
850
+ text += `\nšŸ“‹ Detailed Records:\n\n`;
851
+ for (const r of records) {
852
+ text += ` ─── ${r.id} ───\n`;
853
+ text += ` Time: ${r.timestamp}\n`;
854
+ text += ` Domain: ${r.domain} | Action: ${r.action}\n`;
855
+ text += ` Query: ${r.query}\n`;
856
+ text += ` Result: ${r.result_summary}\n`;
857
+ text += ` Status: ${r.compliant ? "āœ… COMPLIANT" : "āš ļø REVIEW"} | Confidence: ${(r.confidence * 100).toFixed(0)}%\n\n`;
858
+ }
859
+ }
860
+ text += `\nāš ļø Disclaimer: This report is generated from EDITION audit records. `;
861
+ text += `It serves as a structured reference for governance reviews but does not constitute legal certification.`;
862
+ text += `\nšŸ“Œ Data source: EDITION Intelligence Platform (api.edition.sh) — Verified Japan regulatory knowledge.`;
863
+ return { content: [{ type: "text", text }] };
864
+ });
767
865
  // ── Start ───────────────────────────────────────────
768
866
  async function main() {
769
867
  const transport = new stdio_js_1.StdioServerTransport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edition-mcp-server",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "mcpName": "io.github.hiroshic9-png/japan-business-operations",
5
5
  "description": "EDITION — Japan Knowledge Gateway for AI agents. 14 knowledge domains, 6 Skills Packs, 31 MCP tools, Progressive Discovery support. Verified ground truth: regulations, procedures, protocols, calendar, regional, organization, foreign entry, travel, entertainment, daily life, language, food culture, disaster safety, and persistent memory.",
6
6
  "main": "dist/index.js",