resume_smg 0.0.2

Tool to generate a resume of StaticMCP.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::{
    collections::{HashMap, HashSet},
    fs,
};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
    pub resume: Resume,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Resume {
    pub info: PersonalInfo,
    pub experiences: Vec<Experience>,
    pub projects: Vec<Project>,
    pub skills: Vec<Skill>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PersonalInfo {
    pub name: String,
    pub location: String,
    pub phone_number: String,
    pub email: String,
    pub links: HashMap<String, String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Experience {
    pub id: String,
    pub title: String,
    pub employer: String,
    pub start_date: DateTime<Utc>,
    pub end_date: Option<DateTime<Utc>>,
    pub projects: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Project {
    pub id: String,
    pub title: String,
    pub duration: Option<String>,
    pub description: String,
    pub skills: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Skill {
    pub id: String,
    pub name: String,
    #[serde(rename = "type")]
    pub skill_type: String,
    pub category: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPResource {
    pub uri: String,
    pub name: String,
    pub description: String,
    #[serde(rename = "mimeType")]
    pub mime_type: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPToolSchema {
    pub name: String,
    pub description: String,
    #[serde(rename = "inputSchema")]
    pub input_schema: serde_json::Value,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPManifest {
    #[serde(rename = "protocolVersion")]
    pub protocol_version: String,
    pub capabilities: MCPCapabilities,
    #[serde(rename = "serverInfo")]
    pub server_info: MCPServerInfo,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPCapabilities {
    pub resources: Vec<MCPResource>,
    pub tools: Vec<MCPToolSchema>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPServerInfo {
    pub name: String,
    pub version: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPResourceContent {
    pub uri: String,
    #[serde(rename = "mimeType")]
    pub mime_type: String,
    pub text: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPToolResult {
    pub content: Vec<MCPToolContent>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MCPToolContent {
    #[serde(rename = "type")]
    pub content_type: String,
    pub text: String,
}

#[derive(Debug, Clone)]
pub struct ResumeIndex {
    pub skill_to_projects: HashMap<String, Vec<String>>,
    pub skill_to_experiences: HashMap<String, Vec<String>>,
    pub project_to_experiences: HashMap<String, Vec<String>>,
    pub experience_lookup: HashMap<String, Experience>,
    pub project_lookup: HashMap<String, Project>,
    pub skill_lookup: HashMap<String, Skill>,
}

pub struct StaticGenerator {
    pub resume: Resume,
    pub index: ResumeIndex,
    pub output_dir: String,
}

impl StaticGenerator {
    pub fn new(resume: Resume, output_dir: String) -> Self {
        let index = build_index(&resume);
        Self {
            resume,
            index,
            output_dir,
        }
    }

    pub fn generate(&self) -> Result<(), Box<dyn std::error::Error>> {
        fs::create_dir_all(&self.output_dir)?;
        fs::create_dir_all(format!("{}/resources", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools", self.output_dir))?;
        fs::create_dir_all(format!("{}/indexes", self.output_dir))?;

        self.generate_manifest()?;
        self.generate_resources()?;
        self.generate_tool_results()?;
        self.generate_indexes()?;

        println!("Static MCP site generated in: {}", self.output_dir);
        Ok(())
    }

    pub fn generate_manifest(&self) -> Result<(), Box<dyn std::error::Error>> {
        let manifest = MCPManifest {
            protocol_version: "2025-06-18".to_string(),
            capabilities: MCPCapabilities {
                resources: vec![
                    MCPResource {
                        uri: "resume://info".to_string(),
                        name: "Personal Information".to_string(),
                        description: "Basic personal details and contact information".to_string(),
                        mime_type: "application/json".to_string(),
                    },
                    MCPResource {
                        uri: "resume://experiences".to_string(),
                        name: "All Experiences".to_string(),
                        description: "Complete list of work experiences".to_string(),
                        mime_type: "application/json".to_string(),
                    },
                    MCPResource {
                        uri: "resume://projects".to_string(),
                        name: "All Projects".to_string(),
                        description: "Complete list of projects".to_string(),
                        mime_type: "application/json".to_string(),
                    },
                    MCPResource {
                        uri: "resume://skills".to_string(),
                        name: "All Skills".to_string(),
                        description: "Complete list of skills".to_string(),
                        mime_type: "application/json".to_string(),
                    },
                ],
                tools: vec![
                    MCPToolSchema {
                        name: "get_skills_for_project".to_string(),
                        description: "Get all skills used in a specific project".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "project_id": {"type": "string", "description": "Project ID"}
                            },
                            "required": ["project_id"]
                        }),
                    },
                    MCPToolSchema {
                        name: "get_projects_using_skill".to_string(),
                        description: "Get all projects that use a specific skill".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "skill_id": {"type": "string", "description": "Skill ID"}
                            },
                            "required": ["skill_id"]
                        }),
                    },
                    MCPToolSchema {
                        name: "get_experiences_using_skill".to_string(),
                        description: "Get all experiences that involve a specific skill".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "skill_id": {"type": "string", "description": "Skill ID"}
                            },
                            "required": ["skill_id"]
                        }),
                    },
                    MCPToolSchema {
                        name: "get_shared_skills".to_string(),
                        description: "Get skills shared between two projects".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "project_a": {"type": "string", "description": "First project ID"},
                                "project_b": {"type": "string", "description": "Second project ID"}
                            },
                            "required": ["project_a", "project_b"]
                        }),
                    },
                    MCPToolSchema {
                        name: "find_skill_clusters".to_string(),
                        description: "Find clusters of skills that frequently appear together".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {},
                            "required": []
                        }),
                    },
                    MCPToolSchema {
                        name: "get_basic_info".to_string(),
                        description: "Get basic personal information".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {},
                            "required": []
                        }),
                    },
                    MCPToolSchema {
                        name: "get_resume_indexes".to_string(),
                        description: "Get index-level details for skills, projects, and experiences".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {},
                            "required": []
                        }),
                    },
                    MCPToolSchema {
                        name: "get_experience_details".to_string(),
                        description: "Get detailed information about a specific experience".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "experience_id": {"type": "string", "description": "Experience ID"}
                            },
                            "required": ["experience_id"]
                        }),
                    },
                    MCPToolSchema {
                        name: "get_project_details".to_string(),
                        description: "Get detailed information about a specific project".to_string(),
                        input_schema: serde_json::json!({
                            "type": "object",
                            "properties": {
                                "project_id": {"type": "string", "description": "Project ID"}
                            },
                            "required": ["project_id"]
                        }),
                    },
                ],
            },
            server_info: MCPServerInfo {
                name: "static-resume-mcp".to_string(),
                version: "0.1.0".to_string(),
            },
        };

        let manifest_json = serde_json::to_string_pretty(&manifest)?;
        fs::write(format!("{}/mcp.json", self.output_dir), manifest_json)?;
        Ok(())
    }

    pub fn generate_resources(&self) -> Result<(), Box<dyn std::error::Error>> {
        let info_content = MCPResourceContent {
            uri: "resume://info".to_string(),
            mime_type: "application/json".to_string(),
            text: serde_json::to_string_pretty(&self.resume.info)?,
        };
        fs::write(
            format!("{}/resources/info.json", self.output_dir),
            serde_json::to_string_pretty(&info_content)?,
        )?;

        let experiences_content = MCPResourceContent {
            uri: "resume://experiences".to_string(),
            mime_type: "application/json".to_string(),
            text: serde_json::to_string_pretty(&self.resume.experiences)?,
        };
        fs::write(
            format!("{}/resources/experiences.json", self.output_dir),
            serde_json::to_string_pretty(&experiences_content)?,
        )?;

        let projects_content = MCPResourceContent {
            uri: "resume://projects".to_string(),
            mime_type: "application/json".to_string(),
            text: serde_json::to_string_pretty(&self.resume.projects)?,
        };
        fs::write(
            format!("{}/resources/projects.json", self.output_dir),
            serde_json::to_string_pretty(&projects_content)?,
        )?;

        let skills_content = MCPResourceContent {
            uri: "resume://skills".to_string(),
            mime_type: "application/json".to_string(),
            text: serde_json::to_string_pretty(&self.resume.skills)?,
        };
        fs::write(
            format!("{}/resources/skills.json", self.output_dir),
            serde_json::to_string_pretty(&skills_content)?,
        )?;

        Ok(())
    }

    pub fn generate_tool_results(&self) -> Result<(), Box<dyn std::error::Error>> {
        fs::create_dir_all(format!("{}/tools/get_skills_for_project", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_projects_using_skill", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_experiences_using_skill", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_shared_skills", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_basic_info", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_resume_indexes", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_experience_details", self.output_dir))?;
        fs::create_dir_all(format!("{}/tools/get_project_details", self.output_dir))?;

        for project in &self.resume.projects {
            let skills: Vec<&Skill> = project
                .skills
                .iter()
                .filter_map(|id| self.index.skill_lookup.get(id))
                .collect();
            
            let result = MCPToolResult {
                content: vec![MCPToolContent {
                    content_type: "text".to_string(),
                    text: serde_json::to_string_pretty(&skills)?,
                }],
            };
            
            fs::write(
                format!("{}/tools/get_skills_for_project/{}.json", self.output_dir, project.id),
                serde_json::to_string_pretty(&result)?,
            )?;
        }

        for skill in &self.resume.skills {
            let project_ids = self
                .index
                .skill_to_projects
                .get(&skill.id)
                .cloned()
                .unwrap_or_default();
            
            let projects: Vec<&Project> = project_ids
                .iter()
                .filter_map(|id| self.index.project_lookup.get(id))
                .collect();
            
            let result = MCPToolResult {
                content: vec![MCPToolContent {
                    content_type: "text".to_string(),
                    text: serde_json::to_string_pretty(&projects)?,
                }],
            };
            
            fs::write(
                format!("{}/tools/get_projects_using_skill/{}.json", self.output_dir, skill.id),
                serde_json::to_string_pretty(&result)?,
            )?;
        }

        for skill in &self.resume.skills {
            let experience_ids = self
                .index
                .skill_to_experiences
                .get(&skill.id)
                .cloned()
                .unwrap_or_default();
            
            let experiences: Vec<&Experience> = experience_ids
                .iter()
                .filter_map(|id| self.index.experience_lookup.get(id))
                .collect();
            
            let result = MCPToolResult {
                content: vec![MCPToolContent {
                    content_type: "text".to_string(),
                    text: serde_json::to_string_pretty(&experiences)?,
                }],
            };
            
            fs::write(
                format!("{}/tools/get_experiences_using_skill/{}.json", self.output_dir, skill.id),
                serde_json::to_string_pretty(&result)?,
            )?;
        }

        for (i, project_a) in self.resume.projects.iter().enumerate() {
            fs::create_dir_all(format!("{}/tools/get_shared_skills/{}", self.output_dir, project_a.id))?;
            
            for project_b in self.resume.projects.iter().skip(i + 1) {
                let skills_a: HashSet<String> = project_a.skills.iter().cloned().collect();
                let skills_b: HashSet<String> = project_b.skills.iter().cloned().collect();
                
                let shared: Vec<&Skill> = skills_a
                    .intersection(&skills_b)
                    .filter_map(|id| self.index.skill_lookup.get(id))
                    .collect();
                
                let result = MCPToolResult {
                    content: vec![MCPToolContent {
                        content_type: "text".to_string(),
                        text: serde_json::to_string_pretty(&shared)?,
                    }],
                };
                
                fs::write(
                    format!("{}/tools/get_shared_skills/{}/{}.json", self.output_dir, project_a.id, project_b.id),
                    serde_json::to_string_pretty(&result)?,
                )?;
                
                fs::create_dir_all(format!("{}/tools/get_shared_skills/{}", self.output_dir, project_b.id))?;
                fs::write(
                    format!("{}/tools/get_shared_skills/{}/{}.json", self.output_dir, project_b.id, project_a.id),
                    serde_json::to_string_pretty(&result)?,
                )?;
            }
        }

        let mut skill_combinations = HashMap::new();
        
        for project in &self.resume.projects {
            if project.skills.len() > 1 {
                for i in 0..project.skills.len() {
                    for j in (i + 1)..project.skills.len() {
                        let mut pair = vec![project.skills[i].clone(), project.skills[j].clone()];
                        pair.sort();
                        let key = pair.join(",");
                        
                        skill_combinations
                            .entry(key)
                            .or_insert_with(Vec::new)
                            .push(project.id.clone());
                    }
                }
                
                if project.skills.len() >= 3 {
                    let mut sorted_skills = project.skills.clone();
                    sorted_skills.sort();
                    let key = sorted_skills.join(",");
                    skill_combinations
                        .entry(key)
                        .or_insert_with(Vec::new)
                        .push(project.id.clone());
                }
            }
        }
        
        let significant_clusters: HashMap<String, Vec<String>> = skill_combinations
            .into_iter()
            .filter(|(_, projects)| projects.len() > 1)
            .collect();
        
        let result = MCPToolResult {
            content: vec![MCPToolContent {
                content_type: "text".to_string(),
                text: serde_json::to_string_pretty(&significant_clusters)?,
            }],
        };
        
        fs::write(
            format!("{}/tools/find_skill_clusters.json", self.output_dir),
            serde_json::to_string_pretty(&result)?,
        )?;

        let basic_info_result = MCPToolResult {
            content: vec![MCPToolContent {
                content_type: "text".to_string(),
                text: serde_json::to_string_pretty(&self.resume.info)?,
            }],
        };
        fs::write(
            format!("{}/tools/get_basic_info.json", self.output_dir),
            serde_json::to_string_pretty(&basic_info_result)?
        )?;

        let indexes = serde_json::json!({
            "skill_to_projects": &self.index.skill_to_projects,
            "skill_to_experiences": &self.index.skill_to_experiences,
            "project_to_experiences": &self.index.project_to_experiences,
        });
        let indexes_result = MCPToolResult {
            content: vec![MCPToolContent {
                content_type: "text".to_string(),
                text: serde_json::to_string_pretty(&indexes)?,
            }],
        };
        fs::write(
            format!("{}/tools/get_resume_indexes.json", self.output_dir),
            serde_json::to_string_pretty(&indexes_result)?
        )?;

        for experience in &self.resume.experiences {
            let result = MCPToolResult {
                content: vec![MCPToolContent {
                    content_type: "text".to_string(),
                    text: serde_json::to_string_pretty(&experience)?,
                }],
            };
            
            fs::write(
                format!("{}/tools/get_experience_details/{}.json", self.output_dir, experience.id),
                serde_json::to_string_pretty(&result)?,
            )?;
        }

        for project in &self.resume.projects {
            let result = MCPToolResult {
                content: vec![MCPToolContent {
                    content_type: "text".to_string(),
                    text: serde_json::to_string_pretty(&project)?,
                }],
            };
            
            fs::write(
                format!("{}/tools/get_project_details/{}.json", self.output_dir, project.id),
                serde_json::to_string_pretty(&result)?,
            )?;
        }

        Ok(())
    }

    pub fn generate_indexes(&self) -> Result<(), Box<dyn std::error::Error>> {
        fs::write(
            format!("{}/indexes/skill_to_projects.json", self.output_dir),
            serde_json::to_string_pretty(&self.index.skill_to_projects)?,
        )?;
        fs::write(
            format!("{}/indexes/skill_to_experiences.json", self.output_dir),
            serde_json::to_string_pretty(&self.index.skill_to_experiences)?,
        )?;
        fs::write(
            format!("{}/indexes/project_to_experiences.json", self.output_dir),
            serde_json::to_string_pretty(&self.index.project_to_experiences)?,
        )?;

        Ok(())
    }
}

pub fn build_index(resume: &Resume) -> ResumeIndex {
    let mut skill_to_projects = HashMap::new();
    let mut skill_to_experiences = HashMap::new();
    let mut project_to_experiences = HashMap::new();
    
    let experience_lookup: HashMap<String, Experience> = 
        resume.experiences.iter().map(|e| (e.id.clone(), e.clone())).collect();
    let project_lookup: HashMap<String, Project> = 
        resume.projects.iter().map(|p| (p.id.clone(), p.clone())).collect();
    let skill_lookup: HashMap<String, Skill> = 
        resume.skills.iter().map(|s| (s.id.clone(), s.clone())).collect();

    for project in &resume.projects {
        for skill_id in &project.skills {
            skill_to_projects
                .entry(skill_id.clone())
                .or_insert_with(Vec::new)
                .push(project.id.clone());
        }
    }

    for experience in &resume.experiences {
        for project_id in &experience.projects {
            project_to_experiences
                .entry(project_id.clone())
                .or_insert_with(Vec::new)
                .push(experience.id.clone());

            if let Some(project) = project_lookup.get(project_id) {
                for skill_id in &project.skills {
                    skill_to_experiences
                        .entry(skill_id.clone())
                        .or_insert_with(Vec::new)
                        .push(experience.id.clone());
                }
            }
        }
    }

    for vec in skill_to_experiences.values_mut() {
        vec.sort();
        vec.dedup();
    }

    ResumeIndex {
        skill_to_projects,
        skill_to_experiences,
        project_to_experiences,
        experience_lookup,
        project_lookup,
        skill_lookup,
    }
}